mirror of
https://git.decapod.one/brethil/dotfiles
synced 2024-12-22 08:21:40 +01:00
zsh: theme: get rid of more functions
This commit is contained in:
parent
81d8c56836
commit
030903dcd7
|
@ -3,33 +3,31 @@
|
|||
# See "EXPANSION OF PROMPT SEQUENCES" in `man zshmisc`
|
||||
# Note: Most of the expansions/color sequences can be tested using `print -P`
|
||||
|
||||
function user_prompt(){
|
||||
# prints hostname on an orange background if on an ssh connection, adds username if root
|
||||
|
||||
local user='%(!.%K{160}%F{255}%B%n%b%k%f.)' # prints 'root' on a red background if user is root
|
||||
local host='%K{202}%B%F{255}%m%f%k%b' # bold host name on an orange background
|
||||
local open_bracket='%(!.[.)'
|
||||
local close_bracket='%(!.].)'
|
||||
local at='%(!.@.)'
|
||||
if [[ -n $SSH_CONNECTION ]]; then
|
||||
echo "[${user}${at}${host}]"
|
||||
else
|
||||
echo "${open_bracket}${user}${close_bracket}"
|
||||
fi
|
||||
}
|
||||
local user='%(!.%K{160}%F{255}%B%n%b%k%f.)' # prints 'root' on a red background if user is root
|
||||
local host='%K{202}%B%F{255}%m%f%k%b' # bold host name on an orange background
|
||||
local open_bracket='%(!.[.)'
|
||||
local close_bracket='%(!.].)'
|
||||
local at='%(!.@.)'
|
||||
local user_prompt
|
||||
if [[ -n $SSH_CONNECTION ]]; then
|
||||
user_prompt="[${user}${at}${host}]"
|
||||
else
|
||||
user_prompt="${open_bracket}${user}${close_bracket}"
|
||||
fi
|
||||
|
||||
local job_prompt="%(1j.%B%K{202}%F{220} %j %k%b.)"
|
||||
|
||||
function shlvl_prompt() {
|
||||
# Shows SHLVL on a magenta background if SHLVL > 1 (2 if in a tmux session)
|
||||
if [[ -z "$TMUX" ]]; then
|
||||
echo "%(2L.%K{161}%F{255}%B %L %f%b%k.)"
|
||||
else
|
||||
echo "%(3L.%K{161}%F{255}%B $((SHLVL-1)) %f%b%k.)"
|
||||
fi
|
||||
}
|
||||
|
||||
# TODO: add truncation using
|
||||
local shlvl_prompt
|
||||
# Shows SHLVL on a magenta background if SHLVL > 1 (2 if in a tmux session)
|
||||
if [[ -z "$TMUX" ]]; then
|
||||
shlvl_prompt="%(2L.%K{161}%F{255}%B %L %f%b%k.)"
|
||||
else
|
||||
shlvl_prompt="%(3L.%K{161}%F{255}%B $((SHLVL-1)) %f%b%k.)"
|
||||
fi
|
||||
|
||||
# Shows last 3 items in path if there are more than 4
|
||||
local path_prompt='[%F{green}%(4~:…/%3~:%~)%f]'
|
||||
|
||||
|
@ -57,12 +55,12 @@ ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE=">"
|
|||
ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE="<"
|
||||
ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE="<>"
|
||||
|
||||
|
||||
local BOLD_PURPLE='%B%F{5}'
|
||||
local CLEAR='%f%b'
|
||||
local venv
|
||||
function virtualenv_info {
|
||||
[ -z "$VIRTUAL_ENV" ] && return
|
||||
|
||||
local BOLD_PURPLE='%B%F{5}'
|
||||
local CLEAR='%f%b'
|
||||
local venv
|
||||
venv="$(basename "$VIRTUAL_ENV")"
|
||||
if [[ "$venv" == ".venv" ]]; then
|
||||
venv="$(basename $(dirname "$VIRTUAL_ENV") )"
|
||||
|
@ -88,7 +86,7 @@ export MODE_INDICATOR="[%B%K{red}nav%k%b]" # red background
|
|||
export INSERT_MODE_INDICATOR="[%B%K{28}ins%k%b]" # green background
|
||||
|
||||
# put it all together
|
||||
PROMPT='$(virtualenv_info)$(user_prompt)'"${path_prompt}${git_prompt}${job_prompt}"'$(shlvl_prompt)'"${prompt_too_long}${prompt_with_previous_return_status}"
|
||||
PROMPT='$(virtualenv_info)'"${user_prompt}${path_prompt}${git_prompt}${job_prompt}${shlvl_prompt}${prompt_too_long}${prompt_with_previous_return_status}"
|
||||
|
||||
# Right prompt is just return code and time
|
||||
RPS1="${return_code_RPS1}"'$(vi_mode_prompt_info)[%*]'
|
||||
|
|
Loading…
Reference in New Issue
Block a user