Add ssh and key related aliases and reformat all fish files

This commit is contained in:
mitchell 2020-10-31 18:13:25 -04:00
parent 0ef8fb571a
commit 7a361e5260
10 changed files with 72 additions and 54 deletions

View file

@ -13,7 +13,7 @@ function fish_prompt --description 'Write out the prompt'
end
# Set jobs num, based on exit code of jobs command
if jobs > /dev/null
if jobs >/dev/null
set -l jobs_out (jobs -c)
set jobs_num '[' (set_color grey) (count $jobs_out) (set_color normal) '] '
end
@ -31,49 +31,53 @@ function fish_prompt --description 'Write out the prompt'
if test $fish_key_bindings = 'fish_vi_key_bindings'
switch "$fish_bind_mode"
case 'insert'
set suffix (set_color brblue) $suffix (set_color normal)
case 'default'
set suffix '###'
case 'visual'
set suffix (set_color bryellow) '<~#' (set_color normal)
case 'insert'
set suffix (set_color brblue) $suffix (set_color normal)
case 'default'
set suffix '###'
case 'visual'
set suffix (set_color bryellow) '<~#' (set_color normal)
end
end
case '*'
set color_cwd $fish_color_cwd
set suffix '$~>'
if test $fish_key_bindings = 'fish_vi_key_bindings'
switch "$fish_bind_mode"
case 'insert'
set suffix (set_color brblue) $suffix (set_color normal)
case 'default'
set suffix '<$>'
case 'visual'
set suffix (set_color bryellow) '<~$' (set_color normal)
case 'insert'
set suffix (set_color brblue) $suffix (set_color normal)
case 'default'
set suffix '<$>'
case 'visual'
set suffix (set_color bryellow) '<~$' (set_color normal)
end
end
end
# Set user_prefix, based on whether or not inside of ssh session.
if test -n "$SSH_CLIENT"; set user_prefix $USER @ (prompt_hostname) ' '; end
if test -n "$SSH_CLIENT"
set user_prefix $USER @ (prompt_hostname) ' '
end
# Show current git branch, based on git commands only.
if git status > /dev/null 2>&1
if git status >/dev/null 2>&1
set -l branch_color green
set -l git_status (git status)
if string match 'Changes not staged for commit:' $git_status > /dev/null
or string match 'Untracked files:' $git_status > /dev/null
if string match 'Changes not staged for commit:' $git_status >/dev/null
or string match 'Untracked files:' $git_status >/dev/null
set branch_color red
else if string match 'Changes to be committed:' $git_status > /dev/null
else if string match 'Changes to be committed:' $git_status >/dev/null
set branch_color yellow
end
set -l cur_branch (string sub -s 3 (string match -r '^\* .*$' (git branch)))
if string match -q '(HEAD detached*' $cur_branch; set cur_branch 'detached'; end
if string match -q '(HEAD detached*' $cur_branch
set cur_branch 'detached'
end
if test -n "$cur_branch"
set -l cur_branch_len (string length $cur_branch)
@ -83,10 +87,10 @@ function fish_prompt --description 'Write out the prompt'
end
end
if string match 'Your branch is ahead of*' $git_status > /dev/null
set cur_branch $cur_branch \u21A5
else if string match 'Your branch is behind*' $git_status > /dev/null
set cur_branch $cur_branch \u21A7
if string match 'Your branch is ahead of*' $git_status >/dev/null
set cur_branch $cur_branch \u21A5
else if string match 'Your branch is behind*' $git_status >/dev/null
set cur_branch $cur_branch \u21A7
end
set git_branch ' on ' (set_color $branch_color) $cur_branch (set_color normal)