How can I use the arrow sign in my bash prompt? Announcing the arrival of Valued Associate...
Is there night in Alpha Complex?
How to get a flat-head nail out of a piece of wood?
Short story about astronauts fertilizing soil with their own bodies
What does 丫 mean? 丫是什么意思?
Is a copyright notice with a non-existent name be invalid?
Why are current probes so expensive?
Did pre-Columbian Americans know the spherical shape of the Earth?
Random body shuffle every night—can we still function?
NIntegrate on a solution of a matrix ODE
Why did Bronn offer to be Tyrion Lannister's champion in trial by combat?
Where did Ptolemy compare the Earth to the distance of fixed stars?
Did John Wesley plagiarize Matthew Henry...?
Weaponising the Grasp-at-a-Distance spell
Inverse square law not accurate for non-point masses?
How do you cope with tons of web fonts when copying and pasting from web pages?
My mentor says to set image to Fine instead of RAW — how is this different from JPG?
"Destructive power" carried by a B-52?
Why do C and C++ allow the expression (int) + 4*5?
Why can't fire hurt Daenerys but it did to Jon Snow in season 1?
How do I find my Spellcasting Ability for my D&D character?
Did any compiler fully use 80-bit floating point?
Does the universe have a fixed centre of mass?
How to make triangles with rounded sides and corners? (squircle with 3 sides)
How to achieve cat-like agility?
How can I use the arrow sign in my bash prompt?
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)How can I shorten my command line (bash) prompt?What does “${debian_chroot:+($debian_chroot)}” do in my terminal prompt?How can I shorten my command line (bash) prompt?Changing behavior of bash prompt when functioning as rootbash prompt chenged itself to a plain “#”how to fix my keyboard after a bash script messed it upHow to add colored git branch to my bash prompt?Prompt doesn't update git branchtab completion missing, ll not found, logout not foundShell prompt customization and cmd behaviorWrapping lines bugs when trying to colour terminal PS1 (even when escaping non printing caracters)New user, broken bash prompt parsing?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
How can I use these red and green arrow signs in the bash prompt?
update 1
This is my .bashrc
file
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}[33[01;32m][33[00m]
[33[01;34m]→ w[33[00m]$ '
else
PS1='${debian_chroot:+($debian_chroot)}→ w$ '
fi
unset color_prompt force_color_prompt
I want this arrow to be colored as @dessert answered before
(turn red and green for false and true command )
bash bashrc prompt
add a comment |
How can I use these red and green arrow signs in the bash prompt?
update 1
This is my .bashrc
file
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}[33[01;32m][33[00m]
[33[01;34m]→ w[33[00m]$ '
else
PS1='${debian_chroot:+($debian_chroot)}→ w$ '
fi
unset color_prompt force_color_prompt
I want this arrow to be colored as @dessert answered before
(turn red and green for false and true command )
bash bashrc prompt
add a comment |
How can I use these red and green arrow signs in the bash prompt?
update 1
This is my .bashrc
file
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}[33[01;32m][33[00m]
[33[01;34m]→ w[33[00m]$ '
else
PS1='${debian_chroot:+($debian_chroot)}→ w$ '
fi
unset color_prompt force_color_prompt
I want this arrow to be colored as @dessert answered before
(turn red and green for false and true command )
bash bashrc prompt
How can I use these red and green arrow signs in the bash prompt?
update 1
This is my .bashrc
file
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}[33[01;32m][33[00m]
[33[01;34m]→ w[33[00m]$ '
else
PS1='${debian_chroot:+($debian_chroot)}→ w$ '
fi
unset color_prompt force_color_prompt
I want this arrow to be colored as @dessert answered before
(turn red and green for false and true command )
bash bashrc prompt
bash bashrc prompt
edited Mar 26 at 15:43
Afshin
asked Mar 26 at 7:58
AfshinAfshin
11510
11510
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can use bash
’s PROMPT_COMMAND
to run a function which builds your prompt, e.g.:
PROMPT_COMMAND=build_prompt
build_prompt() {
EXIT=$? # save exit code of last command
red='[e[0;31m]' # colors
green='[e[0;32m]'
cyan='[e[1;36m]'
reset='[e[0m]'
PS1='${debian_chroot:+($debian_chroot)}' # begin prompt
if [ $EXIT != 0 ]; then # add arrow color dependent on exit code
PS1+="$red"
else
PS1+="$green"
fi
PS1+="→$reset $cyanw$reset \$ " # construct rest of prompt
}
Add this code to your ~/.bashrc
file and open a new terminal or run . ~/.bashrc
in an existing one for the changes to take effect. Note that I added the usual $
at the end, this prints $
normally and #
if you’re root, thus preventing you from running commands as root unwittingly. The false
command is a good way to test the non-zero exit code variant:
If you’re into prompt themeing you should definitely take a look at the zsh
shell (package zsh
), whose famous configuration framework Oh My Zsh alone comes with over hundred themes. Additionally there are many other plugins available, for example the Spaceship ZSH prompt.
Links
- How can I shorten my command line (bash) prompt?
- Bash Prompt with Last Exit Code
- Easy Bash PS1 Generator
- Bash tips: Colors and formatting
- What color codes can I use in my PS1 prompt?
- What does "${debian_chroot:+($debian_chroot)}" do in my terminal prompt?
1
While this is a great plain-bash solution, you could take a look at zsh (as a replacement of bash) and especially the Spaceship prompt
– Richard de Wit
Mar 27 at 7:27
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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%2faskubuntu.com%2fquestions%2f1128757%2fhow-can-i-use-the-arrow-sign-in-my-bash-prompt%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
You can use bash
’s PROMPT_COMMAND
to run a function which builds your prompt, e.g.:
PROMPT_COMMAND=build_prompt
build_prompt() {
EXIT=$? # save exit code of last command
red='[e[0;31m]' # colors
green='[e[0;32m]'
cyan='[e[1;36m]'
reset='[e[0m]'
PS1='${debian_chroot:+($debian_chroot)}' # begin prompt
if [ $EXIT != 0 ]; then # add arrow color dependent on exit code
PS1+="$red"
else
PS1+="$green"
fi
PS1+="→$reset $cyanw$reset \$ " # construct rest of prompt
}
Add this code to your ~/.bashrc
file and open a new terminal or run . ~/.bashrc
in an existing one for the changes to take effect. Note that I added the usual $
at the end, this prints $
normally and #
if you’re root, thus preventing you from running commands as root unwittingly. The false
command is a good way to test the non-zero exit code variant:
If you’re into prompt themeing you should definitely take a look at the zsh
shell (package zsh
), whose famous configuration framework Oh My Zsh alone comes with over hundred themes. Additionally there are many other plugins available, for example the Spaceship ZSH prompt.
Links
- How can I shorten my command line (bash) prompt?
- Bash Prompt with Last Exit Code
- Easy Bash PS1 Generator
- Bash tips: Colors and formatting
- What color codes can I use in my PS1 prompt?
- What does "${debian_chroot:+($debian_chroot)}" do in my terminal prompt?
1
While this is a great plain-bash solution, you could take a look at zsh (as a replacement of bash) and especially the Spaceship prompt
– Richard de Wit
Mar 27 at 7:27
add a comment |
You can use bash
’s PROMPT_COMMAND
to run a function which builds your prompt, e.g.:
PROMPT_COMMAND=build_prompt
build_prompt() {
EXIT=$? # save exit code of last command
red='[e[0;31m]' # colors
green='[e[0;32m]'
cyan='[e[1;36m]'
reset='[e[0m]'
PS1='${debian_chroot:+($debian_chroot)}' # begin prompt
if [ $EXIT != 0 ]; then # add arrow color dependent on exit code
PS1+="$red"
else
PS1+="$green"
fi
PS1+="→$reset $cyanw$reset \$ " # construct rest of prompt
}
Add this code to your ~/.bashrc
file and open a new terminal or run . ~/.bashrc
in an existing one for the changes to take effect. Note that I added the usual $
at the end, this prints $
normally and #
if you’re root, thus preventing you from running commands as root unwittingly. The false
command is a good way to test the non-zero exit code variant:
If you’re into prompt themeing you should definitely take a look at the zsh
shell (package zsh
), whose famous configuration framework Oh My Zsh alone comes with over hundred themes. Additionally there are many other plugins available, for example the Spaceship ZSH prompt.
Links
- How can I shorten my command line (bash) prompt?
- Bash Prompt with Last Exit Code
- Easy Bash PS1 Generator
- Bash tips: Colors and formatting
- What color codes can I use in my PS1 prompt?
- What does "${debian_chroot:+($debian_chroot)}" do in my terminal prompt?
1
While this is a great plain-bash solution, you could take a look at zsh (as a replacement of bash) and especially the Spaceship prompt
– Richard de Wit
Mar 27 at 7:27
add a comment |
You can use bash
’s PROMPT_COMMAND
to run a function which builds your prompt, e.g.:
PROMPT_COMMAND=build_prompt
build_prompt() {
EXIT=$? # save exit code of last command
red='[e[0;31m]' # colors
green='[e[0;32m]'
cyan='[e[1;36m]'
reset='[e[0m]'
PS1='${debian_chroot:+($debian_chroot)}' # begin prompt
if [ $EXIT != 0 ]; then # add arrow color dependent on exit code
PS1+="$red"
else
PS1+="$green"
fi
PS1+="→$reset $cyanw$reset \$ " # construct rest of prompt
}
Add this code to your ~/.bashrc
file and open a new terminal or run . ~/.bashrc
in an existing one for the changes to take effect. Note that I added the usual $
at the end, this prints $
normally and #
if you’re root, thus preventing you from running commands as root unwittingly. The false
command is a good way to test the non-zero exit code variant:
If you’re into prompt themeing you should definitely take a look at the zsh
shell (package zsh
), whose famous configuration framework Oh My Zsh alone comes with over hundred themes. Additionally there are many other plugins available, for example the Spaceship ZSH prompt.
Links
- How can I shorten my command line (bash) prompt?
- Bash Prompt with Last Exit Code
- Easy Bash PS1 Generator
- Bash tips: Colors and formatting
- What color codes can I use in my PS1 prompt?
- What does "${debian_chroot:+($debian_chroot)}" do in my terminal prompt?
You can use bash
’s PROMPT_COMMAND
to run a function which builds your prompt, e.g.:
PROMPT_COMMAND=build_prompt
build_prompt() {
EXIT=$? # save exit code of last command
red='[e[0;31m]' # colors
green='[e[0;32m]'
cyan='[e[1;36m]'
reset='[e[0m]'
PS1='${debian_chroot:+($debian_chroot)}' # begin prompt
if [ $EXIT != 0 ]; then # add arrow color dependent on exit code
PS1+="$red"
else
PS1+="$green"
fi
PS1+="→$reset $cyanw$reset \$ " # construct rest of prompt
}
Add this code to your ~/.bashrc
file and open a new terminal or run . ~/.bashrc
in an existing one for the changes to take effect. Note that I added the usual $
at the end, this prints $
normally and #
if you’re root, thus preventing you from running commands as root unwittingly. The false
command is a good way to test the non-zero exit code variant:
If you’re into prompt themeing you should definitely take a look at the zsh
shell (package zsh
), whose famous configuration framework Oh My Zsh alone comes with over hundred themes. Additionally there are many other plugins available, for example the Spaceship ZSH prompt.
Links
- How can I shorten my command line (bash) prompt?
- Bash Prompt with Last Exit Code
- Easy Bash PS1 Generator
- Bash tips: Colors and formatting
- What color codes can I use in my PS1 prompt?
- What does "${debian_chroot:+($debian_chroot)}" do in my terminal prompt?
edited Mar 28 at 19:02
answered Mar 26 at 8:53
dessertdessert
25.7k674108
25.7k674108
1
While this is a great plain-bash solution, you could take a look at zsh (as a replacement of bash) and especially the Spaceship prompt
– Richard de Wit
Mar 27 at 7:27
add a comment |
1
While this is a great plain-bash solution, you could take a look at zsh (as a replacement of bash) and especially the Spaceship prompt
– Richard de Wit
Mar 27 at 7:27
1
1
While this is a great plain-bash solution, you could take a look at zsh (as a replacement of bash) and especially the Spaceship prompt
– Richard de Wit
Mar 27 at 7:27
While this is a great plain-bash solution, you could take a look at zsh (as a replacement of bash) and especially the Spaceship prompt
– Richard de Wit
Mar 27 at 7:27
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- 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%2faskubuntu.com%2fquestions%2f1128757%2fhow-can-i-use-the-arrow-sign-in-my-bash-prompt%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