Last active
May 3, 2024 04:44
-
-
Save rtviii/782ea28a070d34f13422bab39c14b454 to your computer and use it in GitHub Desktop.
This little shell function toggles your command line prompt to display full path or only the last 2 folders.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PROMPT_COMMAND=prompt_fullpath_toggle | |
export FULL_PATH_PROMPT="0" | |
function prompt_fullpath_toggle() { | |
if [ "$FULL_PATH_PROMPT" = "0" ]; then | |
export PS1="%F{blue}ᢹ%f %n [ %F{green}%10d%f ]${vcs_info_msg_1_} " | |
export FULL_PATH_PROMPT="1" | |
zle reset-prompt | |
elif [ "$FULL_PATH_PROMPT" = "1" ]; then | |
export PS1="%F{blue}ᢹ%f %n [ %F{green}%2d%f ]${vcs_info_msg_1_} " | |
export FULL_PATH_PROMPT="0" | |
zle reset-prompt | |
fi | |
}; | |
zle -N prompt_fullpath_toggle; bindkey '^[Q' prompt_fullpath_toggle | |
PROMPT="%F{blue}ᢹ%f %n [%F{green}%2d%f]${vcs_info_msg_1_} " | |
## for foreign machines(cyan hostname prefixed to user) | |
#PROMPT='%F{blue}ᢹ%f %F{cyan}%M%f.%B%n%b[ %F{green}%2d%f ] ${vcs_info_msg_1_} ' | |
RPROMPT="${vcs_info_msg_0_} " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment