├── demo.gif ├── minimal-terminal-prompt-grayscale.sh ├── LICENSE ├── minimal-terminal-prompt.sh ├── minimal-terminal-prompt.zsh-theme └── readme.md /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lissy93/minimal-terminal-prompt/HEAD/demo.gif -------------------------------------------------------------------------------- /minimal-terminal-prompt-grayscale.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ## Text Styles 4 | RESET='\[\e[0m\]' # What color will comand outputs be in 5 | BOLD='\[\e[1m\]' # BOLD 6 | 7 | ## Config 8 | SHOW_GIT=true 9 | 10 | ## If this is a valid git repo, echo the current branch name 11 | parse_git_branch() { 12 | git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' 13 | } 14 | 15 | ## Build-up what will be the final PS1 string 16 | set_bash_prompt(){ 17 | PS1="${RESET}\n" 18 | PS1+="@\u ➜ ${BOLD}\w ${RESET}" 19 | 20 | if [ "$SHOW_GIT" = true ] && [ "$(git rev-parse --is-inside-work-tree 2> /dev/null)" = true ] ; then 21 | PS1+="$(parse_git_branch)" 22 | fi 23 | 24 | PS1+="\n└─▶" 25 | PS1+="${RESET} \$ " 26 | } 27 | 28 | ## Done, now just set the PS1 prompt :) 29 | PROMPT_COMMAND=set_bash_prompt 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017-2022 Alicia Sykes 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /minimal-terminal-prompt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ## Define all the colors 4 | COL_USER_HOST='\[\e[35m\]' # The color of 'user@host.ext' 5 | COL_CURSOR='\[\e[35m\]' # The color of the trailing cursor arrow 6 | COL_CURRENT_PATH='\[\e[37m\]' # The color of the current directory full path 7 | COL_GIT_STATUS_CLEAN='\[\e[93m\]' # Color of fresh git branch name, with NO changes 8 | COL_GIT_STATUS_CHANGES='\[\e[92m\]' # Color of git branch, affter its diverged from remote 9 | 10 | ## Text Styles 11 | RESET='\[\e[0m\]' # What color will comand outputs be in 12 | BOLD='\[\e[1m\]' # BOLD 13 | 14 | ## Config 15 | SHOW_GIT=true 16 | 17 | ## If this is a valid git repo, echo the current branch name 18 | parse_git_branch() { 19 | git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' 20 | } 21 | 22 | ## Echos what color the git branch should be (depending on changes) 23 | parse_git_changes() { 24 | if [[ $(git status --porcelain) ]]; then 25 | echo ${COL_GIT_STATUS_CLEAN} 26 | else 27 | echo ${COL_GIT_STATUS_CHANGES} 28 | fi 29 | } 30 | 31 | ## Build-up what will be the final PS1 string 32 | set_bash_prompt(){ 33 | PS1="${RESET}" 34 | PS1+="${BOLD}${COL_USER_HOST}\u @ \h ${RESET}${COL_CURRENT_PATH}\w " 35 | 36 | if [ "$SHOW_GIT" = true ] && [ "$(git rev-parse --is-inside-work-tree 2> /dev/null)" = true ] ; then 37 | PS1+="$(parse_git_changes)" 38 | PS1+="$(parse_git_branch)" 39 | fi 40 | 41 | PS1+="\n${COL_CURSOR}└─▶ " 42 | PS1+="${RESET}" 43 | } 44 | 45 | ## Done, now just set the PS1 prompt :) 46 | PROMPT_COMMAND=set_bash_prompt 47 | -------------------------------------------------------------------------------- /minimal-terminal-prompt.zsh-theme: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | # FILE: minimal-terminal-prompt.zsh-theme 3 | # DESCRIPTION: oh-my-zsh theme file to show simple git status 4 | # AUTHOR: Alicia Sykes (alicia@as93.net) 5 | # VERSION: 1.0.0 6 | # SCREENSHOT: screenshot.gif 7 | # REPO: https://github.com/Lissy93/minimal-terminal-prompt 8 | # DIRECT LINK: https://raw.githubusercontent.com/Lissy93/minimal-terminal-prompt/master/minimal-terminal-prompt.zsh-theme 9 | # ------------------------------------------------------------------------------ 10 | 11 | 12 | 13 | # color vars 14 | eval col_gray='$FG[240]' 15 | eval col_primary='$FG[032]' 16 | eval col_diff='$FG[214]' 17 | eval col_diff='$FG[214]' 18 | eval col_same='$FG[034]' 19 | 20 | 21 | if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="green"; fi 22 | local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" 23 | 24 | # primary prompt 25 | PROMPT='$col_gray% ┌┄┈------------------------------------------------------ 26 | $col_gray% ├%{$reset_color%}$col_primary%~\ 27 | $(git_prompt_info) \ 28 | $col_primary%(?.%{$col_primary%}.%{$col_diff%}) 29 | └─▶%{$reset_color%} ' 30 | PROMPT2='%{$fg[red]%}\ %{$reset_color%}' 31 | RPS1='${return_code}' 32 | 33 | 34 | 35 | # right prompt 36 | if type "virtualenv_prompt_info" > /dev/null 37 | then 38 | RPROMPT='$(virtualenv_prompt_info)$col_gray%n@%m%{$reset_color%} [$(date +%H:%M)]%' 39 | else 40 | RPROMPT='$col_gray%n@%m%{$reset_color%} [$(date +%H:%M)]%%' 41 | fi 42 | 43 | 44 | # git settings 45 | ZSH_THEME_GIT_PROMPT_PREFIX="$col_primary($col_same" 46 | ZSH_THEME_GIT_PROMPT_CLEAN="" 47 | ZSH_THEME_GIT_PROMPT_DIRTY="$col_diff+%{$reset_color%}" 48 | ZSH_THEME_GIT_PROMPT_SUFFIX="$col_primary)%{$reset_color%}" 49 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | 2 |

📟 Minimal Terminal Prompt

3 |

4 | A clean PS1 bash prompt, showing user, host, pathname and git status
5 |

6 | 7 | 8 |

9 | 10 | 11 | 12 | ### Bash Installation 13 | 14 | Clone and cd into the repo, then copy the desired PS1 .sh file contents into your `~/.bashrc`. 15 | Then just reload your bash profile (either restart your cmd, or run the source command) 16 | 17 | ```bash 18 | git clone https://github.com/Lissy93/minimal-terminal-prompt.git 19 | 20 | cd minimal-terminal-prompt 21 | 22 | cat minimal-terminal-prompt.sh >> ~/.bashrc 23 | 24 | source ~/.bashrc 25 | ``` 26 | 27 | Done 😎 28 | 29 | _**Note, for Mac OS X:** Because by default OS X starts a login session first, 30 | the file `~/.bash_profile` can be used in place of `~/.bashrc`. Read more about this on this 31 | [GNU Documentation Article](https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html)._ 32 | 33 | 34 | **References and Further Reading:** All the information you could ever want to know about customising your bash PS1 prompt 35 | can be found on this detailed Linux Documentation and how-to guide, by Giles Orr: 36 | [TLDP: Bash Prompt How-To](http://tldp.org/HOWTO/Bash-Prompt-HOWTO/) 37 | 38 | 39 | ### ZSH Installation 40 | 41 | To install this theme for use in [Oh-My-Zsh](https://github.com/robbyrussell/oh-my-zsh), 42 | clone this repository into your OMZ `custom/themes` directory. 43 | 44 | ```bash 45 | $ git clone https://github.com/Lissy93/minimal-terminal-prompt.git ~/.oh-my-zsh/custom/themes 46 | ``` 47 | 48 | You then need to select this theme in your ~/.zshrc: 49 | 50 | ```bash 51 | ZSH_THEME="minimal-terminal-prompt" 52 | ``` 53 | 54 | Done 😎 55 | 56 | For more information, [see this guide about setting ZSH themes](https://github.com/robbyrussell/oh-my-zsh/wiki/Customization#overriding-and-adding-themes). 57 | 58 | 59 | 60 |
61 | 62 | 63 |

64 | © Alicia Sykes 2017
65 | Licensed under MIT
66 | 67 |

68 | 69 | 70 | 82 | 83 | --------------------------------------------------------------------------------