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