[fish] Hydro, fisher, and a few other bits.
This commit is contained in:
parent
5338e989ab
commit
83c5cb970a
137
fish/.config/fish/conf.d/hydro.fish
Normal file
137
fish/.config/fish/conf.d/hydro.fish
Normal file
|
@ -0,0 +1,137 @@
|
|||
status is-interactive || exit
|
||||
|
||||
set --global _hydro_git _hydro_git_$fish_pid
|
||||
|
||||
function $_hydro_git --on-variable $_hydro_git
|
||||
commandline --function repaint
|
||||
end
|
||||
|
||||
function _hydro_pwd --on-variable PWD --on-variable hydro_ignored_git_paths --on-variable fish_prompt_pwd_dir_length
|
||||
set --local git_root (command git --no-optional-locks rev-parse --show-toplevel 2>/dev/null)
|
||||
set --local git_base (string replace --all --regex -- "^.*/" "" "$git_root")
|
||||
set --local path_sep /
|
||||
|
||||
test "$fish_prompt_pwd_dir_length" = 0 && set path_sep
|
||||
|
||||
if set --query git_root[1] && ! contains -- $git_root $hydro_ignored_git_paths
|
||||
set --erase _hydro_skip_git_prompt
|
||||
else
|
||||
set --global _hydro_skip_git_prompt
|
||||
end
|
||||
|
||||
set --global _hydro_pwd (
|
||||
string replace --ignore-case -- ~ \~ $PWD |
|
||||
string replace -- "/$git_base/" /:/ |
|
||||
string replace --regex --all -- "(\.?[^/]{"(
|
||||
string replace --regex --all -- '^$' 1 "$fish_prompt_pwd_dir_length"
|
||||
)"})[^/]*/" "\$1$path_sep" |
|
||||
string replace -- : "$git_base" |
|
||||
string replace --regex -- '([^/]+)$' "\x1b[1m\$1\x1b[22m" |
|
||||
string replace --regex --all -- '(?!^/$)/|^$' "\x1b[2m/\x1b[22m"
|
||||
)
|
||||
end
|
||||
|
||||
function _hydro_postexec --on-event fish_postexec
|
||||
set --local last_status $pipestatus
|
||||
set --global _hydro_status "$_hydro_newline$_hydro_color_prompt$hydro_symbol_prompt"
|
||||
|
||||
for code in $last_status
|
||||
if test $code -ne 0
|
||||
set --global _hydro_status "$_hydro_color_error| "(echo $last_status)" $_hydro_newline$_hydro_color_prompt$_hydro_color_error$hydro_symbol_prompt"
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
test "$CMD_DURATION" -lt $hydro_cmd_duration_threshold && set _hydro_cmd_duration && return
|
||||
|
||||
set --local secs (math --scale=1 $CMD_DURATION/1000 % 60)
|
||||
set --local mins (math --scale=0 $CMD_DURATION/60000 % 60)
|
||||
set --local hours (math --scale=0 $CMD_DURATION/3600000)
|
||||
|
||||
set --local out
|
||||
|
||||
test $hours -gt 0 && set --local --append out $hours"h"
|
||||
test $mins -gt 0 && set --local --append out $mins"m"
|
||||
test $secs -gt 0 && set --local --append out $secs"s"
|
||||
|
||||
set --global _hydro_cmd_duration "$out "
|
||||
end
|
||||
|
||||
function _hydro_prompt --on-event fish_prompt
|
||||
set --query _hydro_status || set --global _hydro_status "$_hydro_newline$_hydro_color_prompt$hydro_symbol_prompt"
|
||||
set --query _hydro_pwd || _hydro_pwd
|
||||
|
||||
command kill $_hydro_last_pid 2>/dev/null
|
||||
|
||||
set --query _hydro_skip_git_prompt && set $_hydro_git && return
|
||||
|
||||
fish --private --command "
|
||||
set branch (
|
||||
command git symbolic-ref --short HEAD 2>/dev/null ||
|
||||
command git describe --tags --exact-match HEAD 2>/dev/null ||
|
||||
command git rev-parse --short HEAD 2>/dev/null |
|
||||
string replace --regex -- '(.+)' '@\$1'
|
||||
)
|
||||
|
||||
test -z \"\$$_hydro_git\" && set --universal $_hydro_git \"\$branch \"
|
||||
|
||||
! command git diff-index --quiet HEAD 2>/dev/null ||
|
||||
count (command git ls-files --others --exclude-standard) >/dev/null && set info \"$hydro_symbol_git_dirty\"
|
||||
|
||||
for fetch in $hydro_fetch false
|
||||
command git rev-list --count --left-right @{upstream}...@ 2>/dev/null |
|
||||
read behind ahead
|
||||
|
||||
switch \"\$behind \$ahead\"
|
||||
case \" \" \"0 0\"
|
||||
case \"0 *\"
|
||||
set upstream \" $hydro_symbol_git_ahead\$ahead\"
|
||||
case \"* 0\"
|
||||
set upstream \" $hydro_symbol_git_behind\$behind\"
|
||||
case \*
|
||||
set upstream \" $hydro_symbol_git_ahead\$ahead $hydro_symbol_git_behind\$behind\"
|
||||
end
|
||||
|
||||
set --universal $_hydro_git \"\$branch\$info\$upstream \"
|
||||
|
||||
test \$fetch = true && command git fetch --no-tags 2>/dev/null
|
||||
end
|
||||
" &
|
||||
|
||||
set --global _hydro_last_pid $last_pid
|
||||
end
|
||||
|
||||
function _hydro_fish_exit --on-event fish_exit
|
||||
set --erase $_hydro_git
|
||||
end
|
||||
|
||||
function _hydro_uninstall --on-event hydro_uninstall
|
||||
set --names |
|
||||
string replace --filter --regex -- "^(_?hydro_)" "set --erase \$1" |
|
||||
source
|
||||
functions --erase (functions --all | string match --entire --regex "^_?hydro_")
|
||||
end
|
||||
|
||||
set --global hydro_color_normal (set_color normal)
|
||||
|
||||
for color in hydro_color_{pwd,git,error,prompt,duration}
|
||||
function $color --on-variable $color --inherit-variable color
|
||||
set --query $color && set --global _$color (set_color $$color)
|
||||
end && $color
|
||||
end
|
||||
|
||||
function hydro_multiline --on-variable hydro_multiline
|
||||
if test "$hydro_multiline" = true
|
||||
set --global _hydro_newline "\n"
|
||||
else
|
||||
set --global _hydro_newline ""
|
||||
end
|
||||
end && hydro_multiline
|
||||
|
||||
set --query hydro_color_error || set --global hydro_color_error $fish_color_error
|
||||
set --query hydro_symbol_prompt || set --global hydro_symbol_prompt ❱
|
||||
set --query hydro_symbol_git_dirty || set --global hydro_symbol_git_dirty •
|
||||
set --query hydro_symbol_git_ahead || set --global hydro_symbol_git_ahead ↑
|
||||
set --query hydro_symbol_git_behind || set --global hydro_symbol_git_behind ↓
|
||||
set --query hydro_multiline || set --global hydro_multiline false
|
||||
set --query hydro_cmd_duration_threshold || set --global hydro_cmd_duration_threshold 1000
|
|
@ -3,7 +3,6 @@ if status is-interactive
|
|||
|
||||
source ~/.asdf/asdf.fish
|
||||
|
||||
starship init fish | source
|
||||
end
|
||||
|
||||
export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
jorgebucaran/fisher
|
||||
jorgebucaran/hydro
|
||||
|
|
|
@ -3,33 +3,46 @@
|
|||
SETUVAR --export QT_QPA_PLATFORM:
|
||||
SETUVAR __fish_initialized:3400
|
||||
SETUVAR _fisher_jorgebucaran_2F_fisher_files:\x7e/\x2econfig/fish/functions/fisher\x2efish\x1e\x7e/\x2econfig/fish/completions/fisher\x2efish
|
||||
SETUVAR _fisher_plugins:jorgebucaran/fisher
|
||||
SETUVAR _fisher_jorgebucaran_2F_hydro_files:\x7e/\x2econfig/fish/functions/fish_mode_prompt\x2efish\x1e\x7e/\x2econfig/fish/functions/fish_prompt\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/hydro\x2efish
|
||||
SETUVAR _fisher_plugins:jorgebucaran/fisher\x1ejorgebucaran/hydro
|
||||
SETUVAR _fisher_upgraded_to_4_4:\x1d
|
||||
SETUVAR fish_color_autosuggestion:brblack
|
||||
SETUVAR fish_color_cancel:\x2dr
|
||||
SETUVAR fish_color_command:blue
|
||||
SETUVAR fish_color_comment:red
|
||||
SETUVAR fish_color_cwd:green
|
||||
SETUVAR _hydro_git_273879:main\u2022\x20\u21912\x20
|
||||
SETUVAR fish_color_autosuggestion:4D5566
|
||||
SETUVAR fish_color_cancel:\x2d\x2dreverse
|
||||
SETUVAR fish_color_command:39BAE6
|
||||
SETUVAR fish_color_comment:626A73
|
||||
SETUVAR fish_color_cwd:59C2FF
|
||||
SETUVAR fish_color_cwd_root:red
|
||||
SETUVAR fish_color_end:green
|
||||
SETUVAR fish_color_error:brred
|
||||
SETUVAR fish_color_escape:brcyan
|
||||
SETUVAR fish_color_end:F29668
|
||||
SETUVAR fish_color_error:FF3333
|
||||
SETUVAR fish_color_escape:95E6CB
|
||||
SETUVAR fish_color_history_current:\x2d\x2dbold
|
||||
SETUVAR fish_color_host:normal
|
||||
SETUVAR fish_color_host_remote:yellow
|
||||
SETUVAR fish_color_normal:normal
|
||||
SETUVAR fish_color_operator:brcyan
|
||||
SETUVAR fish_color_param:cyan
|
||||
SETUVAR fish_color_quote:yellow
|
||||
SETUVAR fish_color_redirection:cyan\x1e\x2d\x2dbold
|
||||
SETUVAR fish_color_search_match:bryellow\x1e\x2d\x2dbackground\x3dbrblack
|
||||
SETUVAR fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblack
|
||||
SETUVAR fish_color_host_remote:\x1d
|
||||
SETUVAR fish_color_keyword:\x1d
|
||||
SETUVAR fish_color_match:F07178
|
||||
SETUVAR fish_color_normal:B3B1AD
|
||||
SETUVAR fish_color_operator:E6B450
|
||||
SETUVAR fish_color_option:\x1d
|
||||
SETUVAR fish_color_param:B3B1AD
|
||||
SETUVAR fish_color_quote:C2D94C
|
||||
SETUVAR fish_color_redirection:FFEE99
|
||||
SETUVAR fish_color_search_match:\x2d\x2dbackground\x3dE6B450
|
||||
SETUVAR fish_color_selection:\x2d\x2dbackground\x3dE6B450
|
||||
SETUVAR fish_color_status:red
|
||||
SETUVAR fish_color_user:brgreen
|
||||
SETUVAR fish_color_valid_path:\x2d\x2dunderline
|
||||
SETUVAR fish_key_bindings:fish_default_key_bindings
|
||||
SETUVAR fish_pager_color_background:\x1d
|
||||
SETUVAR fish_pager_color_completion:normal
|
||||
SETUVAR fish_pager_color_description:yellow\x1e\x2di
|
||||
SETUVAR fish_pager_color_description:B3A06D
|
||||
SETUVAR fish_pager_color_prefix:normal\x1e\x2d\x2dbold\x1e\x2d\x2dunderline
|
||||
SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan
|
||||
SETUVAR fish_pager_color_selected_background:\x2dr
|
||||
SETUVAR fish_pager_color_secondary_background:\x1d
|
||||
SETUVAR fish_pager_color_secondary_completion:\x1d
|
||||
SETUVAR fish_pager_color_secondary_description:\x1d
|
||||
SETUVAR fish_pager_color_secondary_prefix:\x1d
|
||||
SETUVAR fish_pager_color_selected_background:\x2d\x2dbackground\x3dE6B450
|
||||
SETUVAR fish_pager_color_selected_completion:\x1d
|
||||
SETUVAR fish_pager_color_selected_description:\x1d
|
||||
SETUVAR fish_pager_color_selected_prefix:\x1d
|
||||
|
|
21
fish/.config/fish/functions/fish_mode_prompt.fish
Normal file
21
fish/.config/fish/functions/fish_mode_prompt.fish
Normal file
|
@ -0,0 +1,21 @@
|
|||
function fish_mode_prompt
|
||||
if test "$fish_key_bindings" != fish_default_key_bindings
|
||||
set --local vi_mode_color
|
||||
set --local vi_mode_symbol
|
||||
switch $fish_bind_mode
|
||||
case default
|
||||
set vi_mode_color (set_color $fish_color_selection)
|
||||
set vi_mode_symbol N
|
||||
case insert
|
||||
set vi_mode_color (set_color $fish_color_selection)
|
||||
set vi_mode_symbol I
|
||||
case replace replace_one
|
||||
set vi_mode_color (set_color $fish_color_match)
|
||||
set vi_mode_symbol R
|
||||
case visual
|
||||
set vi_mode_color (set_color $fish_color_match)
|
||||
set vi_mode_symbol V
|
||||
end
|
||||
echo -e "$vi_mode_color $vi_mode_symbol \x1b[0m "
|
||||
end
|
||||
end
|
56
fish/.config/fish/functions/fish_prompt.fish
Normal file
56
fish/.config/fish/functions/fish_prompt.fish
Normal file
|
@ -0,0 +1,56 @@
|
|||
function fish_prompt --description 'Write out the prompt'
|
||||
set -l last_status $status
|
||||
|
||||
prompt_login
|
||||
|
||||
echo -n ':'
|
||||
|
||||
# PWD
|
||||
set_color $fish_color_cwd
|
||||
echo -n (prompt_pwd)
|
||||
set_color normal
|
||||
|
||||
set -q __fish_git_prompt_showdirtystate
|
||||
or set -g __fish_git_prompt_showdirtystate 1
|
||||
set -q __fish_git_prompt_showuntrackedfiles
|
||||
or set -g __fish_git_prompt_showuntrackedfiles 1
|
||||
set -q __fish_git_prompt_showcolorhints
|
||||
or set -g __fish_git_prompt_showcolorhints 1
|
||||
set -q __fish_git_prompt_color_untrackedfiles
|
||||
or set -g __fish_git_prompt_color_untrackedfiles yellow
|
||||
set -q __fish_git_prompt_char_untrackedfiles
|
||||
or set -g __fish_git_prompt_char_untrackedfiles '?'
|
||||
set -q __fish_git_prompt_color_invalidstate
|
||||
or set -g __fish_git_prompt_color_invalidstate red
|
||||
set -q __fish_git_prompt_char_invalidstate
|
||||
or set -g __fish_git_prompt_char_invalidstate '!'
|
||||
set -q __fish_git_prompt_color_dirtystate
|
||||
or set -g __fish_git_prompt_color_dirtystate blue
|
||||
set -q __fish_git_prompt_char_dirtystate
|
||||
or set -g __fish_git_prompt_char_dirtystate '*'
|
||||
set -q __fish_git_prompt_char_stagedstate
|
||||
or set -g __fish_git_prompt_char_stagedstate '✚'
|
||||
set -q __fish_git_prompt_color_cleanstate
|
||||
or set -g __fish_git_prompt_color_cleanstate green
|
||||
set -q __fish_git_prompt_char_cleanstate
|
||||
or set -g __fish_git_prompt_char_cleanstate '✓'
|
||||
set -q __fish_git_prompt_color_stagedstate
|
||||
or set -g __fish_git_prompt_color_stagedstate yellow
|
||||
set -q __fish_git_prompt_color_branch_dirty
|
||||
or set -g __fish_git_prompt_color_branch_dirty red
|
||||
set -q __fish_git_prompt_color_branch_staged
|
||||
or set -g __fish_git_prompt_color_branch_staged yellow
|
||||
set -q __fish_git_prompt_color_branch
|
||||
or set -g __fish_git_prompt_color_branch green
|
||||
set -q __fish_git_prompt_char_stateseparator
|
||||
or set -g __fish_git_prompt_char_stateseparator '⚡'
|
||||
fish_vcs_prompt '|%s'
|
||||
echo
|
||||
|
||||
if not test $last_status -eq 0
|
||||
set_color $fish_color_error
|
||||
end
|
||||
|
||||
echo -n '➤ '
|
||||
set_color normal
|
||||
end
|
Loading…
Reference in a new issue