How to save and restore the default prompt (when PS1 is not defined)?Proper place to put shell prompt(PS1)...
Is "The life is beautiful" incorrect or just very non-idiomatic?
Does norwegian.no airline overbook flights?
Immutable builder and updater
Read file lines into shell line separated by space
Are there any elected officials in the U.S. who are not legislators, judges, or constitutional officers?
How to find out the average duration of the peer-review process for a given journal?
Is there any practical application for performing a double Fourier transform? ...or an inverse Fourier transform on a time-domain input?
Is there any music source code for sound chips?
LeetCode: Group Anagrams C#
How do I get a decreased-by-one x in a foreach loop?
Was it ever possible to target a zone?
Thank God it's Friday, tomorrow is THE weekend. Why the definite article?
I don't have the theoretical background in my PhD topic. I can't justify getting the degree
Why do banks “park” their money at the European Central Bank?
What would be the challenges to taking off and landing a typical passenger jet at FL300?
Tensorflow - logistic regrssion -oneHot Encoder - Transformed array of differt size for both train and test
Who was president of the USA?
Position a tabular on the corner of a slide
How should I face my manager if I make a mistake because a senior coworker explained something incorrectly to me?
An interview question: What's the number of String objects being created?
Would the Republic of Ireland and Northern Ireland be interested in reuniting?
French abbreviation for comparing two items ("vs")
Why are non-collision-resistant hash functions considered insecure for signing self-generated information
Is a player able to change alignment midway through an adventure?
How to save and restore the default prompt (when PS1 is not defined)?
Proper place to put shell prompt(PS1) when use sh/bash/zsh together$PS1 on Ubuntu VM does not match actual promptProblem with command promp cycling when using colors and trying to put git branches on the command promptHow can I shorten my customized PS1 prompt?How does Git change the shell prompt in Aptana Studio's Cygwin Terminal?tmux not colorizing PS1 promptBash prompt (PS1) broken and spews errors
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
In a shared cluster I work on, the environment settings for new accounts does not include a prompt setting, as far as I can tell. In particular, PS1
is not set. And yet, when one logs into a new account, one gets a rather fancy prompt, featuring the username and the basename of the current directory.
I want to save this prompt (e.g. in an environment variable like ORIGINAL_PS1
) before replacing it with my preferred prompt, so that I can restore it later if desired1.
How can I extract the prompt definition from the current prompt?
I am primarily interested in the answer to this question for bash
, but if there's something analogous for zsh
, please let me know.
1 I rather like the default prompt, but for everyday use I prefer to use a "git
-aware" prompt. That said, although I find the latter extremely helpful 99.999% of the time, ocassionally I cd
to a git
repo that is sufficiently messed up that it causes the prompt's generation to become unacceptably slow. For those rare circumstances, I'd like to be able to run export PS1=$ORIGINAL_PS1
.
bash zsh prompt
add a comment |
In a shared cluster I work on, the environment settings for new accounts does not include a prompt setting, as far as I can tell. In particular, PS1
is not set. And yet, when one logs into a new account, one gets a rather fancy prompt, featuring the username and the basename of the current directory.
I want to save this prompt (e.g. in an environment variable like ORIGINAL_PS1
) before replacing it with my preferred prompt, so that I can restore it later if desired1.
How can I extract the prompt definition from the current prompt?
I am primarily interested in the answer to this question for bash
, but if there's something analogous for zsh
, please let me know.
1 I rather like the default prompt, but for everyday use I prefer to use a "git
-aware" prompt. That said, although I find the latter extremely helpful 99.999% of the time, ocassionally I cd
to a git
repo that is sufficiently messed up that it causes the prompt's generation to become unacceptably slow. For those rare circumstances, I'd like to be able to run export PS1=$ORIGINAL_PS1
.
bash zsh prompt
2
DoesORIGINAL_PS1=$PS1
work for you?
– fd0
yesterday
2
Just to comment on the very last bit of the question:PS1
never has to be exported. It's purely a shell variable and no child processes of the shell needs to inherit it.
– Kusalananda♦
yesterday
2
IfPS1
is not set, then that's probably notbash
. what does echo $prompt say?
– mosvy
yesterday
@Kusalananda: That observation actually solved the mystery: I had looked at the output ofprintenv
for the prompt's definition, mistakingly thinking that it was exported. Thank you all. All your comments nailed it, each in a different way!
– kjo
yesterday
add a comment |
In a shared cluster I work on, the environment settings for new accounts does not include a prompt setting, as far as I can tell. In particular, PS1
is not set. And yet, when one logs into a new account, one gets a rather fancy prompt, featuring the username and the basename of the current directory.
I want to save this prompt (e.g. in an environment variable like ORIGINAL_PS1
) before replacing it with my preferred prompt, so that I can restore it later if desired1.
How can I extract the prompt definition from the current prompt?
I am primarily interested in the answer to this question for bash
, but if there's something analogous for zsh
, please let me know.
1 I rather like the default prompt, but for everyday use I prefer to use a "git
-aware" prompt. That said, although I find the latter extremely helpful 99.999% of the time, ocassionally I cd
to a git
repo that is sufficiently messed up that it causes the prompt's generation to become unacceptably slow. For those rare circumstances, I'd like to be able to run export PS1=$ORIGINAL_PS1
.
bash zsh prompt
In a shared cluster I work on, the environment settings for new accounts does not include a prompt setting, as far as I can tell. In particular, PS1
is not set. And yet, when one logs into a new account, one gets a rather fancy prompt, featuring the username and the basename of the current directory.
I want to save this prompt (e.g. in an environment variable like ORIGINAL_PS1
) before replacing it with my preferred prompt, so that I can restore it later if desired1.
How can I extract the prompt definition from the current prompt?
I am primarily interested in the answer to this question for bash
, but if there's something analogous for zsh
, please let me know.
1 I rather like the default prompt, but for everyday use I prefer to use a "git
-aware" prompt. That said, although I find the latter extremely helpful 99.999% of the time, ocassionally I cd
to a git
repo that is sufficiently messed up that it causes the prompt's generation to become unacceptably slow. For those rare circumstances, I'd like to be able to run export PS1=$ORIGINAL_PS1
.
bash zsh prompt
bash zsh prompt
asked yesterday
kjokjo
4,51413 gold badges41 silver badges73 bronze badges
4,51413 gold badges41 silver badges73 bronze badges
2
DoesORIGINAL_PS1=$PS1
work for you?
– fd0
yesterday
2
Just to comment on the very last bit of the question:PS1
never has to be exported. It's purely a shell variable and no child processes of the shell needs to inherit it.
– Kusalananda♦
yesterday
2
IfPS1
is not set, then that's probably notbash
. what does echo $prompt say?
– mosvy
yesterday
@Kusalananda: That observation actually solved the mystery: I had looked at the output ofprintenv
for the prompt's definition, mistakingly thinking that it was exported. Thank you all. All your comments nailed it, each in a different way!
– kjo
yesterday
add a comment |
2
DoesORIGINAL_PS1=$PS1
work for you?
– fd0
yesterday
2
Just to comment on the very last bit of the question:PS1
never has to be exported. It's purely a shell variable and no child processes of the shell needs to inherit it.
– Kusalananda♦
yesterday
2
IfPS1
is not set, then that's probably notbash
. what does echo $prompt say?
– mosvy
yesterday
@Kusalananda: That observation actually solved the mystery: I had looked at the output ofprintenv
for the prompt's definition, mistakingly thinking that it was exported. Thank you all. All your comments nailed it, each in a different way!
– kjo
yesterday
2
2
Does
ORIGINAL_PS1=$PS1
work for you?– fd0
yesterday
Does
ORIGINAL_PS1=$PS1
work for you?– fd0
yesterday
2
2
Just to comment on the very last bit of the question:
PS1
never has to be exported. It's purely a shell variable and no child processes of the shell needs to inherit it.– Kusalananda♦
yesterday
Just to comment on the very last bit of the question:
PS1
never has to be exported. It's purely a shell variable and no child processes of the shell needs to inherit it.– Kusalananda♦
yesterday
2
2
If
PS1
is not set, then that's probably not bash
. what does echo $prompt say?– mosvy
yesterday
If
PS1
is not set, then that's probably not bash
. what does echo $prompt say?– mosvy
yesterday
@Kusalananda: That observation actually solved the mystery: I had looked at the output of
printenv
for the prompt's definition, mistakingly thinking that it was exported. Thank you all. All your comments nailed it, each in a different way!– kjo
yesterday
@Kusalananda: That observation actually solved the mystery: I had looked at the output of
printenv
for the prompt's definition, mistakingly thinking that it was exported. Thank you all. All your comments nailed it, each in a different way!– kjo
yesterday
add a comment |
1 Answer
1
active
oldest
votes
ORIGINAL_PS1=$PS1
would save the value of the primary prompt variable to a new variable.
The PS1
variable is a shell variable that is not exported, i.e. it's not an environment variable that is inherited by child processes.
In the zsh
shell, you may want to additionally save the "right primary prompt", RPS1
, if that is used. The primary prompt is called PS1
in zsh
, just as in bash
.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f536840%2fhow-to-save-and-restore-the-default-prompt-when-ps1-is-not-defined%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
ORIGINAL_PS1=$PS1
would save the value of the primary prompt variable to a new variable.
The PS1
variable is a shell variable that is not exported, i.e. it's not an environment variable that is inherited by child processes.
In the zsh
shell, you may want to additionally save the "right primary prompt", RPS1
, if that is used. The primary prompt is called PS1
in zsh
, just as in bash
.
add a comment |
ORIGINAL_PS1=$PS1
would save the value of the primary prompt variable to a new variable.
The PS1
variable is a shell variable that is not exported, i.e. it's not an environment variable that is inherited by child processes.
In the zsh
shell, you may want to additionally save the "right primary prompt", RPS1
, if that is used. The primary prompt is called PS1
in zsh
, just as in bash
.
add a comment |
ORIGINAL_PS1=$PS1
would save the value of the primary prompt variable to a new variable.
The PS1
variable is a shell variable that is not exported, i.e. it's not an environment variable that is inherited by child processes.
In the zsh
shell, you may want to additionally save the "right primary prompt", RPS1
, if that is used. The primary prompt is called PS1
in zsh
, just as in bash
.
ORIGINAL_PS1=$PS1
would save the value of the primary prompt variable to a new variable.
The PS1
variable is a shell variable that is not exported, i.e. it's not an environment variable that is inherited by child processes.
In the zsh
shell, you may want to additionally save the "right primary prompt", RPS1
, if that is used. The primary prompt is called PS1
in zsh
, just as in bash
.
answered yesterday
Kusalananda♦Kusalananda
161k18 gold badges318 silver badges505 bronze badges
161k18 gold badges318 silver badges505 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f536840%2fhow-to-save-and-restore-the-default-prompt-when-ps1-is-not-defined%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Does
ORIGINAL_PS1=$PS1
work for you?– fd0
yesterday
2
Just to comment on the very last bit of the question:
PS1
never has to be exported. It's purely a shell variable and no child processes of the shell needs to inherit it.– Kusalananda♦
yesterday
2
If
PS1
is not set, then that's probably notbash
. what does echo $prompt say?– mosvy
yesterday
@Kusalananda: That observation actually solved the mystery: I had looked at the output of
printenv
for the prompt's definition, mistakingly thinking that it was exported. Thank you all. All your comments nailed it, each in a different way!– kjo
yesterday