ZSH: Makes prompt shorter in narrow terminals
This is mainly achieved by no longer showing the full path. If the terminal is less than 100 characters, it will show a preceding icon, >> then the bottom most folder name. The >> indicates that folders have been missed. I have added an icon for my dotfiles folder
This commit is contained in:
parent
c88b6fa18a
commit
983896f644
1 changed files with 11 additions and 6 deletions
|
@ -8,9 +8,10 @@ prompt_dir(){
|
||||||
gitReposIcon=""
|
gitReposIcon=""
|
||||||
magentoSiteIcon=" "
|
magentoSiteIcon=" "
|
||||||
dropboxIcon=""
|
dropboxIcon=""
|
||||||
|
dotfilesIcon=""
|
||||||
seperator=" "
|
seperator=" "
|
||||||
seperatorDual=" "
|
seperatorDual=" "
|
||||||
root=" $seperator"
|
root=" "
|
||||||
# Gets the path.
|
# Gets the path.
|
||||||
local current_path="$(print -P "%~")"
|
local current_path="$(print -P "%~")"
|
||||||
|
|
||||||
|
@ -54,15 +55,21 @@ prompt_dir(){
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Replace Dropbox with icon
|
# Replace Dropbox with icon
|
||||||
current_path=$(echo $current_path | sed -r -e "s/$homeIcon\/Dropbox/$dropboxIcon/")
|
current_path=$(echo $current_path | sed -r -e "s/$homeIcon\/Dropbox/$dropboxIcon/")
|
||||||
|
|
||||||
# Replace GitRepos with icon
|
# Replace GitRepos with icon
|
||||||
current_path=$(echo $current_path | sed -r -e "s/$homeIcon\/GitRepos/$gitReposIcon/")
|
current_path=$(echo $current_path | sed -r -e "s/$homeIcon\/GitRepos/$gitReposIcon/")
|
||||||
|
|
||||||
|
# Replace GitRepos with icon
|
||||||
|
current_path=$(echo $current_path | sed -r -e "s/$homeIcon\/.dotfiles/$dotfilesIcon/")
|
||||||
|
|
||||||
# Set the root
|
# Set the root
|
||||||
current_path=$(echo $current_path | sed -r -e "s/^\//$root/g")
|
current_path=$(echo $current_path | sed -r -e "s/^\//$root\//g")
|
||||||
|
|
||||||
|
if [[ $(tput cols) -lt 100 ]]; then
|
||||||
|
current_path=$(echo $current_path | sed -r -e "s/\/.*\//\/\//g")
|
||||||
|
fi
|
||||||
|
|
||||||
# Set the dual seperator
|
# Set the dual seperator
|
||||||
current_path=$(echo $current_path | sed -r -e "s/\/\//$seperatorDual/g")
|
current_path=$(echo $current_path | sed -r -e "s/\/\//$seperatorDual/g")
|
||||||
|
@ -250,9 +257,7 @@ set_prompts(){
|
||||||
background="$(echo "$segment" | sed -n '2p')"
|
background="$(echo "$segment" | sed -n '2p')"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
invisibleSeperator=$(echo -e '\u2063')
|
PROMPT="$PROMPT $(seperator "$background")$(resetColor)"
|
||||||
|
|
||||||
PROMPT="$PROMPT $(seperator "$background")$(resetColor)$invisibleSeperator"
|
|
||||||
|
|
||||||
#$(resetColor)
|
#$(resetColor)
|
||||||
RPROMPT="$(resetColor)$(prompt_last_exit_code "$RETVAL")$(resetColor)"
|
RPROMPT="$(resetColor)$(prompt_last_exit_code "$RETVAL")$(resetColor)"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue