Tools, binding for fzf cd
This commit is contained in:
parent
bde0ce2e51
commit
5632cf75f5
|
@ -1,128 +1,130 @@
|
||||||
# prompt
|
# prompt
|
||||||
function get_hostname
|
function get_hostname
|
||||||
if test (uname) = Linux || test (uname) = Darwin
|
if test (uname) = Linux || test (uname) = Darwin
|
||||||
has_command hostname && hostname | cut -d. -f1 || cat /etc/hostname
|
has_command hostname && hostname | cut -d. -f1 || cat /etc/hostname
|
||||||
else
|
else
|
||||||
# assume bsd
|
# assume bsd
|
||||||
hostname | head -n 1 | cut -d. -f1
|
hostname | head -n 1 | cut -d. -f1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function fish_greeting
|
function fish_greeting
|
||||||
_prompt_prefix
|
_prompt_prefix
|
||||||
printf "%s\n" (date)
|
printf "%s\n" (date)
|
||||||
end
|
end
|
||||||
|
|
||||||
function preprocess_pwd
|
function preprocess_pwd
|
||||||
test (pwd) = / && echo "/" && return 1
|
test (pwd) = / && echo / && return 1
|
||||||
test (pwd) = $NICE_HOME && echo "~" && return 0
|
test (pwd) = $NICE_HOME && echo "~" && return 0
|
||||||
pwd \
|
pwd \
|
||||||
| cut -c2- \
|
| cut -c2- \
|
||||||
| gawk '{n=split($0,p,"/");for(i=1;i<=n;i++){if(i==n){printf "/%s",p[i]}else{printf "/%.3s",p[i]}}}'
|
| gawk '{n=split($0,p,"/");for(i=1;i<=n;i++){if(i==n){printf "/%s",p[i]}else{printf "/%.3s",p[i]}}}'
|
||||||
end
|
end
|
||||||
|
|
||||||
function _maybe_sudo_prefix
|
function _maybe_sudo_prefix
|
||||||
if set -q SUDO_USER
|
if set -q SUDO_USER
|
||||||
set_color -b yellow black
|
set_color -b yellow black
|
||||||
printf " SUDO "
|
printf " SUDO "
|
||||||
set_color -b normal normal
|
set_color -b normal normal
|
||||||
printf " "
|
printf " "
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function _maybe_aws_profile
|
function _maybe_aws_profile
|
||||||
if set -q AWS_PROFILE && test $AWS_PROFILE = prd
|
if set -q AWS_PROFILE && test $AWS_PROFILE = prd
|
||||||
printf " "
|
printf " "
|
||||||
set_color -b yellow black
|
set_color -b yellow black
|
||||||
printf " AWS_PROFILE=prd "
|
printf " AWS_PROFILE=prd "
|
||||||
set_color -b normal normal
|
set_color -b normal normal
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function _user_and_host
|
function _user_and_host
|
||||||
if test $argv[1] -eq 0
|
if test $argv[1] -eq 0
|
||||||
set_color -b normal blue
|
set_color -b normal blue
|
||||||
else
|
else
|
||||||
set_color -b normal red
|
set_color -b normal red
|
||||||
end
|
end
|
||||||
printf "%s@%s" $USER (get_hostname)
|
printf "%s@%s" $USER (get_hostname)
|
||||||
end
|
end
|
||||||
|
|
||||||
function _cur_work_dir
|
function _cur_work_dir
|
||||||
set_color -b normal magenta
|
set_color -b normal magenta
|
||||||
printf " %s" (preprocess_pwd)
|
printf " %s" (preprocess_pwd)
|
||||||
end
|
end
|
||||||
|
|
||||||
function _last_cmd_duration
|
function _last_cmd_duration
|
||||||
set_color -b normal green
|
set_color -b normal green
|
||||||
set -q CMD_DURATION && printf " %dms" $CMD_DURATION
|
set -q CMD_DURATION && printf " %dms" $CMD_DURATION
|
||||||
end
|
end
|
||||||
|
|
||||||
function _maybe_jobs_summary
|
function _maybe_jobs_summary
|
||||||
if jobs -q
|
if jobs -q
|
||||||
set_color -b normal cyan
|
set_color -b normal cyan
|
||||||
printf " &%d" (jobs -p | wc -l)
|
printf " &%d" (jobs -p | wc -l)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function _user_prompt
|
function _user_prompt
|
||||||
printf "\n"
|
printf "\n"
|
||||||
set_color brblack
|
set_color brblack
|
||||||
if test (id -u) -eq 0
|
if test (id -u) -eq 0
|
||||||
printf '# '
|
printf '# '
|
||||||
else
|
else
|
||||||
printf '$ '
|
printf '$ '
|
||||||
end
|
end
|
||||||
set_color -b normal normal
|
set_color -b normal normal
|
||||||
end
|
end
|
||||||
|
|
||||||
function _maybe_git_summary
|
function _maybe_git_summary
|
||||||
set_color -b normal yellow
|
set_color -b normal yellow
|
||||||
set cur_sha (git rev-parse --short HEAD 2>/dev/null)
|
set cur_sha (git rev-parse --short HEAD 2>/dev/null)
|
||||||
if test $status = 0
|
if test $status = 0
|
||||||
set num_changes (git status --porcelain | wc -l | string trim)
|
set num_changes (git status --porcelain | wc -l | string trim)
|
||||||
if test $num_changes = 0
|
if test $num_changes = 0
|
||||||
set num_changes "✔"
|
set num_changes "✔"
|
||||||
else
|
else
|
||||||
set num_changes "+$num_changes"
|
set num_changes "+$num_changes"
|
||||||
end
|
end
|
||||||
printf " %s %s %s" (git branch --show-current) $cur_sha $num_changes
|
printf " %s %s %s" (git branch --show-current) $cur_sha $num_changes
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function _prompt_marker
|
function _prompt_marker
|
||||||
# printf "%b133;A%b" "\x1b\x5d" "\x1b\x5c"
|
# printf "%b133;A%b" "\x1b\x5d" "\x1b\x5c"
|
||||||
end
|
end
|
||||||
|
|
||||||
function _prompt_continuation_marker
|
function _prompt_continuation_marker
|
||||||
# printf "%b133;A;k=s%b" "\x1b\x5d" "\x1b\x5c"
|
# printf "%b133;A;k=s%b" "\x1b\x5d" "\x1b\x5c"
|
||||||
end
|
end
|
||||||
|
|
||||||
function cmd_marker --on-variable _
|
function cmd_marker --on-variable _
|
||||||
# printf "%b133;C%b" "\x1b\x5d" "\x1b\x5c"
|
# printf "%b133;C%b" "\x1b\x5d" "\x1b\x5c"
|
||||||
end
|
end
|
||||||
|
|
||||||
function _prompt_prefix
|
function _prompt_prefix
|
||||||
set_color -b normal brblack
|
set_color -b normal brblack
|
||||||
printf "# "
|
printf "# "
|
||||||
end
|
end
|
||||||
|
|
||||||
function fish_prompt
|
function fish_prompt
|
||||||
set last_cmd_status $status
|
set last_cmd_status $status
|
||||||
_prompt_marker
|
_prompt_marker
|
||||||
_prompt_prefix
|
_prompt_prefix
|
||||||
_maybe_sudo_prefix
|
_maybe_sudo_prefix
|
||||||
_user_and_host $last_cmd_status
|
_user_and_host $last_cmd_status
|
||||||
_cur_work_dir
|
_cur_work_dir
|
||||||
_maybe_git_summary
|
_maybe_git_summary
|
||||||
_maybe_aws_profile
|
_maybe_aws_profile
|
||||||
_last_cmd_duration
|
_last_cmd_duration
|
||||||
_maybe_jobs_summary
|
_maybe_jobs_summary
|
||||||
_user_prompt
|
_user_prompt
|
||||||
end
|
end
|
||||||
|
|
||||||
function fish_mode_prompt; end
|
function fish_mode_prompt
|
||||||
function fish_right_prompt; end
|
end
|
||||||
|
function fish_right_prompt
|
||||||
|
end
|
||||||
|
|
||||||
# key bindings
|
# key bindings
|
||||||
fish_vi_key_bindings
|
fish_vi_key_bindings
|
||||||
|
@ -143,7 +145,11 @@ bind --mode insert --sets-mode default Jj repaint
|
||||||
bind --mode insert --sets-mode default JJ repaint
|
bind --mode insert --sets-mode default JJ repaint
|
||||||
|
|
||||||
if has_command skim
|
if has_command skim
|
||||||
bind -M insert \cg skim-cd-widget
|
bind -M insert \cg skim-cd-widget
|
||||||
|
end
|
||||||
|
|
||||||
|
if has_command fzf
|
||||||
|
bind -M insert \cg fzf-cd-widget
|
||||||
end
|
end
|
||||||
|
|
||||||
bind -M insert \cp up-or-search
|
bind -M insert \cp up-or-search
|
||||||
|
@ -155,7 +161,7 @@ bind -M insert \cv edit_command_buffer
|
||||||
bind -M default \cv edit_command_buffer
|
bind -M default \cv edit_command_buffer
|
||||||
|
|
||||||
test $PWD = $HOME && begin
|
test $PWD = $HOME && begin
|
||||||
cd $NICE_HOME || cd
|
cd $NICE_HOME || cd
|
||||||
end
|
end
|
||||||
|
|
||||||
# tmux has issues when pasting sometimes where it seems to interpret a newline
|
# tmux has issues when pasting sometimes where it seems to interpret a newline
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
kubectl
|
kubectl
|
||||||
stern
|
stern
|
||||||
libresprite
|
libresprite
|
||||||
|
logseq
|
||||||
audacity
|
audacity
|
||||||
wol
|
wol
|
||||||
shellcheck
|
shellcheck
|
||||||
|
|
Loading…
Reference in a new issue