David Escribano Garcia 修订了这个 Gist 9 years ago. 转到此修订
1 file changed, 6 insertions, 6 deletions
.bash_prompt
| @@ -58,13 +58,13 @@ GIT_PS1_SHOWSTASHSTATE="" | |||
| 58 | 58 | PLAIN='\e[0m' | |
| 59 | 59 | ||
| 60 | 60 | # Text colors | |
| 61 | - | RED='\[\e[31m\]' | |
| 62 | - | GREEN='\[\e[32m\]' | |
| 61 | + | RED='\e[31m' | |
| 62 | + | GREEN='\e[32m' | |
| 63 | 63 | BLUE='\e[1;38;5;25m' | |
| 64 | 64 | LIGHTGRAY='\e[1;38;5;252m' | |
| 65 | 65 | GRAY='\e[1;38;5;242m' | |
| 66 | 66 | WHITE='\e[1;38;5;251m' | |
| 67 | - | ORANGE='\[\e[1;38;5;130m\]' | |
| 67 | + | ORANGE='\e[1;38;5;130m' | |
| 68 | 68 | BOLDBLACK='\e[1;38;5;232m' | |
| 69 | 69 | ||
| 70 | 70 | # Background colors | |
| @@ -115,7 +115,7 @@ P_GIT=' | |||
| 115 | 115 | ' | |
| 116 | 116 | # Number of jobs running | |
| 117 | 117 | P_JOBS=`printf " | |
| 118 | - | echo -n '\[$TASK_TXT\]' | |
| 118 | + | echo -n '\[$S_TASK_TXT\]' | |
| 119 | 119 | case '\j' in | |
| 120 | 120 | 0) echo -n '';; | |
| 121 | 121 | 1) echo -n '𝍠 ' ;; | |
| @@ -129,9 +129,9 @@ P_JOBS=`printf " | |||
| 129 | 129 | # Result of the last command | |
| 130 | 130 | P_CMD_RESULT=" | |
| 131 | 131 | if [ \$LASTCMD -eq 0 ]; then | |
| 132 | - | echo -n ${S_RESULT_OK}$I_OK\[$PLAIN\]; | |
| 132 | + | echo -n \[$S_RESULT_OK\]$I_OK\[$PLAIN\]; | |
| 133 | 133 | else | |
| 134 | - | echo -n ${S_RESULT_KO}$I_KO\[$PLAIN\]; | |
| 134 | + | echo -n \[$S_RESULT_KO\]$I_KO\[$PLAIN\]; | |
| 135 | 135 | fi | |
| 136 | 136 | echo -n ' ' | |
| 137 | 137 | " | |
David Escribano Garcia 修订了这个 Gist 9 years ago. 转到此修订
1 file changed, 4 insertions, 4 deletions
.bash_prompt
| @@ -108,9 +108,9 @@ P_DIR=`printf "\[$S_DIR_BG\]\[$S_DIR_TXT\]$I_ARROW \W "` | |||
| 108 | 108 | P_GIT=' | |
| 109 | 109 | P_GIT_BRANCH=\`type __git_ps1 >/dev/null 2>&1 && __git_ps1 %s\` | |
| 110 | 110 | if [ -z $P_GIT_BRANCH ]; then | |
| 111 | - | echo -en " \[$S_TASK_BG\]\[$S_GIT_ARROW\]$I_ARROW\[$PLAIN\] "; | |
| 111 | + | printf " \[$S_TASK_BG\]\[$S_GIT_ARROW\]$I_ARROW\[$PLAIN\] "; | |
| 112 | 112 | else | |
| 113 | - | echo -en " \[$S_GIT_BG\]\[$S_GIT_ARROW\]$I_ARROW\[$S_GIT_TXT\]$I_GIT $P_GIT_BRANCH \[$S_TASK_BG\]\[$S_TASK_ARROW\]$I_ARROW\[$PLAIN\] "; | |
| 113 | + | printf " \[$S_GIT_BG\]\[$S_GIT_ARROW\]$I_ARROW\[$S_GIT_TXT\]$I_GIT $P_GIT_BRANCH \[$S_TASK_BG\]\[$S_TASK_ARROW\]$I_ARROW\[$PLAIN\] "; | |
| 114 | 114 | fi | |
| 115 | 115 | ' | |
| 116 | 116 | # Number of jobs running | |
| @@ -129,9 +129,9 @@ P_JOBS=`printf " | |||
| 129 | 129 | # Result of the last command | |
| 130 | 130 | P_CMD_RESULT=" | |
| 131 | 131 | if [ \$LASTCMD -eq 0 ]; then | |
| 132 | - | echo -n ${RESULT_OK}${I_OK}\[$PLAIN\]; | |
| 132 | + | echo -n ${S_RESULT_OK}$I_OK\[$PLAIN\]; | |
| 133 | 133 | else | |
| 134 | - | echo -n ${RESULT_KO}${I_KO}\[$PLAIN\]; | |
| 134 | + | echo -n ${S_RESULT_KO}$I_KO\[$PLAIN\]; | |
| 135 | 135 | fi | |
| 136 | 136 | echo -n ' ' | |
| 137 | 137 | " | |
David Escribano Garcia 修订了这个 Gist 9 years ago. 转到此修订
1 file changed, 3 insertions, 3 deletions
.bash_prompt
| @@ -108,14 +108,14 @@ P_DIR=`printf "\[$S_DIR_BG\]\[$S_DIR_TXT\]$I_ARROW \W "` | |||
| 108 | 108 | P_GIT=' | |
| 109 | 109 | P_GIT_BRANCH=\`type __git_ps1 >/dev/null 2>&1 && __git_ps1 %s\` | |
| 110 | 110 | if [ -z $P_GIT_BRANCH ]; then | |
| 111 | - | echo -en " \[${S_TASK_BG}\]\[$S_GIT_ARROW\]$I_ARROW\[$PLAIN\] "; | |
| 111 | + | echo -en " \[$S_TASK_BG\]\[$S_GIT_ARROW\]$I_ARROW\[$PLAIN\] "; | |
| 112 | 112 | else | |
| 113 | - | echo -en " \[${S_GIT_BG}\]\[$S_GIT_ARROW\]$I_ARROW\[$S_GIT_TXT\]$I_GIT $P_GIT_BRANCH \[$S_TASK_BG\]\[$S_TASK_ARROW\]$I_ARROW\[$PLAIN\] "; | |
| 113 | + | echo -en " \[$S_GIT_BG\]\[$S_GIT_ARROW\]$I_ARROW\[$S_GIT_TXT\]$I_GIT $P_GIT_BRANCH \[$S_TASK_BG\]\[$S_TASK_ARROW\]$I_ARROW\[$PLAIN\] "; | |
| 114 | 114 | fi | |
| 115 | 115 | ' | |
| 116 | 116 | # Number of jobs running | |
| 117 | 117 | P_JOBS=`printf " | |
| 118 | - | echo -n '${TASK_TXT}' | |
| 118 | + | echo -n '\[$TASK_TXT\]' | |
| 119 | 119 | case '\j' in | |
| 120 | 120 | 0) echo -n '';; | |
| 121 | 121 | 1) echo -n '𝍠 ' ;; | |
David Escribano Garcia 修订了这个 Gist 9 years ago. 转到此修订
1 file changed, 3 insertions, 2 deletions
.bash_prompt
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | # ------------------------- | |
| 5 | 5 | # Description: | |
| 6 | 6 | # Shows a nicer bash prompt: | |
| 7 | - | # ▶ 💻 mypc ▶ documents ▶ ⎇ master ▶ 𝍠 ✔ | |
| 7 | + | # ▶ 🖳 mypc ▶ documents ▶ ⎇ master ▶ 𝍠 ✔ | |
| 8 | 8 | # -------- --------- ---------- --- ----- | |
| 9 | 9 | # | | | | | | |
| 10 | 10 | # hostname folder git branch jobs last command result | |
| @@ -77,7 +77,8 @@ BGGRAY='\e[48;5;242m' | |||
| 77 | 77 | # Icons (I_ICON_NAME) | |
| 78 | 78 | ####################### | |
| 79 | 79 | I_ARROW="▶" | |
| 80 | - | I_HOST=" 💻 " | |
| 80 | + | #I_HOST=" 💻 " This character casues some issues | |
| 81 | + | I_HOST=" 🖳 " | |
| 81 | 82 | I_GIT=" ⎇ " | |
| 82 | 83 | I_OK="✔" | |
| 83 | 84 | I_KO="✖️" | |
David Escribano Garcia 修订了这个 Gist 9 years ago. 转到此修订
1 file changed, 15 insertions, 9 deletions
.bash_prompt
| @@ -1,22 +1,28 @@ | |||
| 1 | 1 | ################################################################################ | |
| 2 | - | # ------------------------ | |
| 3 | - | # PROMPT CONFIGURATION | |
| 4 | - | # ------------------------ | |
| 2 | + | # ------------------------- | |
| 3 | + | # BASH PROMPT CONFIGURATION | |
| 4 | + | # ------------------------- | |
| 5 | 5 | # Description: | |
| 6 | - | # Shows a nicer prompt | |
| 7 | - | # ▶ 💻 mypc ▶ documents ▶ ⎇ master ▶ 𝍠 ✔ | |
| 6 | + | # Shows a nicer bash prompt: | |
| 7 | + | # ▶ 💻 mypc ▶ documents ▶ ⎇ master ▶ 𝍠 ✔ | |
| 8 | 8 | # -------- --------- ---------- --- ----- | |
| 9 | 9 | # | | | | | | |
| 10 | 10 | # hostname folder git branch jobs last command result | |
| 11 | - | # (See ) | |
| 11 | + | # | |
| 12 | + | # See https://gist.github.com/DavidEGx/7b8d378d55ec03aeefe86e5135ef8514#file-prompt_demo-png | |
| 13 | + | # for a colurful demo. | |
| 14 | + | # | |
| 15 | + | # Last version of this file can be found at | |
| 16 | + | # https://gist.github.com/DavidEGx/7b8d378d55ec03aeefe86e5135ef8514 | |
| 12 | 17 | # | |
| 13 | 18 | # Usage: | |
| 14 | 19 | # 1. Get a copy of __git_ps1 | |
| 15 | 20 | # wget https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh -O ~/.git-prompt.sh | |
| 16 | - | # 2. Get this file in your local directory: | |
| 17 | - | # wget https://gist.githubusercontent.com/DavidEGx/7b8d378d55ec03aeefe86e5135ef8514/raw/90f5520b9402926be18af8d9bf471930715d1b9c/bash_prompt -O ~/.bash_prompt | |
| 18 | - | # 3. Edit your ~/.bashrc, add this line: | |
| 21 | + | # 2. Copy this file in your local diretory as ~/.bash_prompt | |
| 22 | + | # 3. Edit your ~/.bashrc and add this line: | |
| 19 | 23 | # . ~/.bash_prompt | |
| 24 | + | # 4. Reload your ~/.bashrc: | |
| 25 | + | # . ~/.bashrc | |
| 20 | 26 | # | |
| 21 | 27 | # Requires: | |
| 22 | 28 | # * Some unicode font | |
David Escribano Garcia 修订了这个 Gist 9 years ago. 转到此修订
2 files changed, 2 insertions, 2 deletions
bash_prompt 重命名为 .bash_prompt
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | # ------------------------ | |
| 5 | 5 | # Description: | |
| 6 | 6 | # Shows a nicer prompt | |
| 7 | - | # ▶ 💻 mypc ▶ documents ▶ ⎇ master ▶ 𝍠 ✖️ ✔ | |
| 7 | + | # ▶ 💻 mypc ▶ documents ▶ ⎇ master ▶ 𝍠 ✔ | |
| 8 | 8 | # -------- --------- ---------- --- ----- | |
| 9 | 9 | # | | | | | | |
| 10 | 10 | # hostname folder git branch jobs last command result | |
| @@ -14,7 +14,7 @@ | |||
| 14 | 14 | # 1. Get a copy of __git_ps1 | |
| 15 | 15 | # wget https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh -O ~/.git-prompt.sh | |
| 16 | 16 | # 2. Get this file in your local directory: | |
| 17 | - | # wget http://whatever -O ~/.bash_prompt | |
| 17 | + | # wget https://gist.githubusercontent.com/DavidEGx/7b8d378d55ec03aeefe86e5135ef8514/raw/90f5520b9402926be18af8d9bf471930715d1b9c/bash_prompt -O ~/.bash_prompt | |
| 18 | 18 | # 3. Edit your ~/.bashrc, add this line: | |
| 19 | 19 | # . ~/.bash_prompt | |
| 20 | 20 | # | |
prompt_demo.png(文件已创建)
Binary file changes are not shown
David Escribano García 修订了这个 Gist 9 years ago. 转到此修订
1 file changed, 132 insertions
bash_prompt(文件已创建)
| @@ -0,0 +1,132 @@ | |||
| 1 | + | ################################################################################ | |
| 2 | + | # ------------------------ | |
| 3 | + | # PROMPT CONFIGURATION | |
| 4 | + | # ------------------------ | |
| 5 | + | # Description: | |
| 6 | + | # Shows a nicer prompt | |
| 7 | + | # ▶ 💻 mypc ▶ documents ▶ ⎇ master ▶ 𝍠 ✖️ ✔ | |
| 8 | + | # -------- --------- ---------- --- ----- | |
| 9 | + | # | | | | | | |
| 10 | + | # hostname folder git branch jobs last command result | |
| 11 | + | # (See ) | |
| 12 | + | # | |
| 13 | + | # Usage: | |
| 14 | + | # 1. Get a copy of __git_ps1 | |
| 15 | + | # wget https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh -O ~/.git-prompt.sh | |
| 16 | + | # 2. Get this file in your local directory: | |
| 17 | + | # wget http://whatever -O ~/.bash_prompt | |
| 18 | + | # 3. Edit your ~/.bashrc, add this line: | |
| 19 | + | # . ~/.bash_prompt | |
| 20 | + | # | |
| 21 | + | # Requires: | |
| 22 | + | # * Some unicode font | |
| 23 | + | # * 256 colors support in your terminal | |
| 24 | + | # * __git_ps1 | |
| 25 | + | # | |
| 26 | + | # Useful info: | |
| 27 | + | # * http://misc.flogisoft.com/bash/tip_colors_and_formatting | |
| 28 | + | # * https://github.com/morhetz/gruvbox | |
| 29 | + | # * https://gist.github.com/MicahElliott/719710 | |
| 30 | + | # | |
| 31 | + | ################################################################################ | |
| 32 | + | ||
| 33 | + | ####################### | |
| 34 | + | # Git config | |
| 35 | + | ####################### | |
| 36 | + | # Need to get git-prompt: | |
| 37 | + | # wget https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh -O ~/.git-prompt.sh | |
| 38 | + | if [ -f ~/.git-prompt.sh ]; then | |
| 39 | + | . ~/.git-prompt.sh | |
| 40 | + | fi | |
| 41 | + | GIT_PS1_SHOWDIRTYSTATE="" | |
| 42 | + | GIT_PS1_SHOWCOLORHINTS="" | |
| 43 | + | GIT_PS1_SHOWUNTRACKEDFILES="" | |
| 44 | + | GIT_PS1_SHOWUPSTREAM="" | |
| 45 | + | GIT_PS1_SHOWSTASHSTATE="" | |
| 46 | + | ||
| 47 | + | ####################### | |
| 48 | + | # Colors | |
| 49 | + | ####################### | |
| 50 | + | ||
| 51 | + | # Color reset | |
| 52 | + | PLAIN='\e[0m' | |
| 53 | + | ||
| 54 | + | # Text colors | |
| 55 | + | RED='\[\e[31m\]' | |
| 56 | + | GREEN='\[\e[32m\]' | |
| 57 | + | BLUE='\e[1;38;5;25m' | |
| 58 | + | LIGHTGRAY='\e[1;38;5;252m' | |
| 59 | + | GRAY='\e[1;38;5;242m' | |
| 60 | + | WHITE='\e[1;38;5;251m' | |
| 61 | + | ORANGE='\[\e[1;38;5;130m\]' | |
| 62 | + | BOLDBLACK='\e[1;38;5;232m' | |
| 63 | + | ||
| 64 | + | # Background colors | |
| 65 | + | BGBLACK='\e[40m' | |
| 66 | + | BGBLUE='\e[48;5;25m' | |
| 67 | + | BGLIGHTGRAY='\e[48;5;252m' | |
| 68 | + | BGGRAY='\e[48;5;242m' | |
| 69 | + | ||
| 70 | + | ####################### | |
| 71 | + | # Icons (I_ICON_NAME) | |
| 72 | + | ####################### | |
| 73 | + | I_ARROW="▶" | |
| 74 | + | I_HOST=" 💻 " | |
| 75 | + | I_GIT=" ⎇ " | |
| 76 | + | I_OK="✔" | |
| 77 | + | I_KO="✖️" | |
| 78 | + | ||
| 79 | + | ####################### | |
| 80 | + | # Styles (S_STYLE_NAME) | |
| 81 | + | ####################### | |
| 82 | + | S_HOST_BG=$BGLIGHTGRAY | |
| 83 | + | S_HOST_TXT=$BOLDBLACK | |
| 84 | + | S_HOST_ARROW=$GRAY | |
| 85 | + | S_DIR_BG=$BGGRAY | |
| 86 | + | S_DIR_TXT=$LIGHTGRAY | |
| 87 | + | S_GIT_BG=$BGBLUE | |
| 88 | + | S_GIT_TXT=$WHITE | |
| 89 | + | S_GIT_ARROW=$GRAY | |
| 90 | + | S_TASK_BG=$BGBLACK | |
| 91 | + | S_TASK_TXT=$ORANGE | |
| 92 | + | S_TASK_ARROW=$BLUE | |
| 93 | + | S_RESULT_OK=$GREEN | |
| 94 | + | S_RESULT_KO=$RED | |
| 95 | + | ||
| 96 | + | ####################### | |
| 97 | + | # Prompt parts (P_*) | |
| 98 | + | ####################### | |
| 99 | + | P_HOST=`printf "\[$S_HOST_BG\]\[$S_HOST_ARROW\]$I_ARROW\[$S_HOST_TXT\] $I_HOST\h "` | |
| 100 | + | P_DIR=`printf "\[$S_DIR_BG\]\[$S_DIR_TXT\]$I_ARROW \W "` | |
| 101 | + | P_GIT=' | |
| 102 | + | P_GIT_BRANCH=\`type __git_ps1 >/dev/null 2>&1 && __git_ps1 %s\` | |
| 103 | + | if [ -z $P_GIT_BRANCH ]; then | |
| 104 | + | echo -en " \[${S_TASK_BG}\]\[$S_GIT_ARROW\]$I_ARROW\[$PLAIN\] "; | |
| 105 | + | else | |
| 106 | + | echo -en " \[${S_GIT_BG}\]\[$S_GIT_ARROW\]$I_ARROW\[$S_GIT_TXT\]$I_GIT $P_GIT_BRANCH \[$S_TASK_BG\]\[$S_TASK_ARROW\]$I_ARROW\[$PLAIN\] "; | |
| 107 | + | fi | |
| 108 | + | ' | |
| 109 | + | # Number of jobs running | |
| 110 | + | P_JOBS=`printf " | |
| 111 | + | echo -n '${TASK_TXT}' | |
| 112 | + | case '\j' in | |
| 113 | + | 0) echo -n '';; | |
| 114 | + | 1) echo -n '𝍠 ' ;; | |
| 115 | + | 2) echo -n '𝍡 ' ;; | |
| 116 | + | 3) echo -n '𝍢 ' ;; | |
| 117 | + | 4) echo -n '𝍣 ' ;; | |
| 118 | + | *) echo -n '𝍤 ' ;; | |
| 119 | + | esac | |
| 120 | + | echo -n '\[$PLAIN\]' | |
| 121 | + | "` | |
| 122 | + | # Result of the last command | |
| 123 | + | P_CMD_RESULT=" | |
| 124 | + | if [ \$LASTCMD -eq 0 ]; then | |
| 125 | + | echo -n ${RESULT_OK}${I_OK}\[$PLAIN\]; | |
| 126 | + | else | |
| 127 | + | echo -n ${RESULT_KO}${I_KO}\[$PLAIN\]; | |
| 128 | + | fi | |
| 129 | + | echo -n ' ' | |
| 130 | + | " | |
| 131 | + | ||
| 132 | + | PROMPT_COMMAND='LASTCMD=$? PS1="${debian_chroot:+($debian_chroot)}${P_HOST}${P_DIR}\`${P_GIT}\`\`${P_JOBS}\`\`${P_CMD_RESULT}\` "' | |