From 8a209c2fa33889f36f27c4af55e4ba9429fcd98a Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 15 Jun 2022 15:27:59 -0500 Subject: Change bash prompt --- bash/prompt.bash | 56 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/bash/prompt.bash b/bash/prompt.bash index f1bdd69..15fdb41 100644 --- a/bash/prompt.bash +++ b/bash/prompt.bash @@ -1,38 +1,42 @@ # bash prompt -PS1= +if [[ -n "$INSIDE_EMACS" ]]; then + PS1=" \n\[\e[34m\]\$ \[\e[0m\]" +else + PS1= -# user, host, and cwd -PROMPT_DIRTRIM=3 # how many dirs above current to print (rest are '...') -PS1+='\[\e[0;46m\]\u@\h \w' + # user, host, and cwd + PROMPT_DIRTRIM=3 # how many dirs above current to print (rest are '...') + PS1+='\[\e[0;46m\]\u@\h \w' -# git bit -# see https://unix.stackexchange.com/questions/278206 -possible_git_prompt_locations=( - /usr/share/git/git-prompt.sh # Arch, etc. (default?) - /usr/lib/git-core/git-sh-prompt # Debian, Ubuntu ... - /usr/share/git-core/contrib/completion/git-prompt.sh # Fedora ?? - # I have yet to find Alpine's git prompt location. -) + # git bit + # see https://unix.stackexchange.com/questions/278206 + possible_git_prompt_locations=( + /usr/share/git/git-prompt.sh # Arch, etc. (default?) + /usr/lib/git-core/git-sh-prompt # Debian, Ubuntu ... + /usr/share/git-core/contrib/completion/git-prompt.sh # Fedora ?? + # I have yet to find Alpine's git prompt location. + ) -for file in "${possible_git_prompt_locations[@]}"; do + for file in "${possible_git_prompt_locations[@]}"; do if [[ -f "$file" ]]; then - source "$file" && - PS1+='\[\e[35m\]$(__git_ps1)' - break + source "$file" && + PS1+='\[\e[35m\]$(__git_ps1)' + break fi -done + done -# newline -PS1+='\[\e[0m\]\n' + # newline + PS1+='\[\e[0m\]\n' -# exit code (only if error) -__prompt_exit_code() { + # exit code (only if error) + __prompt_exit_code() { local ec=$? (( $ec > 0 )) && - printf "$ec" -} -PS1+='\[\e[31m\]$(__prompt_exit_code)\[\e[0m\]' + printf "$ec" + } + PS1+='\[\e[31m\]$(__prompt_exit_code)\[\e[0m\]' -# delimiter -PS1+='; ' + # delimiter + PS1+='; ' +fi -- cgit 1.4.1-21-gabe81