2020-09-19 15:33:13 +00:00
|
|
|
#!/usr/bin/env fish
|
2020-10-28 17:17:35 +00:00
|
|
|
|
2020-10-26 15:16:34 +00:00
|
|
|
set -gx EDITOR nvim
|
2020-09-19 15:33:13 +00:00
|
|
|
|
2020-10-26 15:16:34 +00:00
|
|
|
# enable fzf completion hotkey
|
2020-10-23 03:49:39 +00:00
|
|
|
set -U FZF_COMPLETE 0
|
2020-10-26 15:16:34 +00:00
|
|
|
# no line-wrapping, good for `docker ps`
|
2020-10-27 10:00:37 +00:00
|
|
|
set -gx LESS "-SRXF"
|
2020-10-26 15:16:34 +00:00
|
|
|
# nvm plugin
|
2020-04-27 06:47:36 +00:00
|
|
|
set -gx nvm_mirror http://npm.taobao.org/mirrors/node
|
2020-10-26 15:16:34 +00:00
|
|
|
# change OTHER-WRITABLE color for `ls` command
|
|
|
|
set -gx LS_COLORS 'ow=34;42;40'
|
|
|
|
# ranger highlighting color theme
|
2020-09-30 08:24:29 +00:00
|
|
|
set -gx HIGHLIGHT_OPTIONS --style=solarized-dark
|
2020-04-27 06:47:36 +00:00
|
|
|
|
2020-10-20 08:09:48 +00:00
|
|
|
# tune git icon for nerdfont
|
2020-10-27 10:00:37 +00:00
|
|
|
set -g __fish_git_prompt_char_upstream_ahead '>'
|
|
|
|
set -g __fish_git_prompt_char_upstream_behind '<'
|
|
|
|
set -g __fish_git_prompt_char_upstream_prefix ''
|
2020-10-20 08:09:48 +00:00
|
|
|
|
2020-10-27 10:00:37 +00:00
|
|
|
set -g __fish_git_prompt_char_stagedstate '●'
|
|
|
|
set -g __fish_git_prompt_char_dirtystate '*'
|
|
|
|
set -g __fish_git_prompt_char_untrackedfiles '+'
|
|
|
|
set -g __fish_git_prompt_char_conflictedstate 'x'
|
|
|
|
set -g __fish_git_prompt_char_cleanstate '✔ '
|
2020-10-20 08:09:48 +00:00
|
|
|
|
2020-04-27 06:47:36 +00:00
|
|
|
function append-path-if-exists
|
2020-10-26 15:16:34 +00:00
|
|
|
if test -e $argv
|
|
|
|
set -gx PATH $argv $PATH
|
2020-04-27 06:47:36 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function source-file-if-exists
|
2020-10-26 15:16:34 +00:00
|
|
|
if test -e $argv
|
|
|
|
source $argv
|
2020-04-27 06:47:36 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
source-file-if-exists ~/.cargo/env
|
2020-09-29 07:09:04 +00:00
|
|
|
|
2020-04-27 06:47:36 +00:00
|
|
|
append-path-if-exists /usr/local/bin
|
2020-09-29 07:09:04 +00:00
|
|
|
append-path-if-exists ~/.local/bin
|
|
|
|
append-path-if-exists ~/.yarn/bin
|
2020-09-22 04:18:01 +00:00
|
|
|
append-path-if-exists /snap/bin
|
2020-04-27 06:47:36 +00:00
|
|
|
|
|
|
|
|
2020-10-26 15:16:34 +00:00
|
|
|
# datetime in filename format
|
2020-04-27 06:47:36 +00:00
|
|
|
function dt
|
2020-10-26 15:16:34 +00:00
|
|
|
date "+%Y%m%d-%H%M%S"
|
2020-04-27 06:47:36 +00:00
|
|
|
end
|
|
|
|
|
2020-10-26 15:16:34 +00:00
|
|
|
# translation
|
2020-04-27 06:47:36 +00:00
|
|
|
function d
|
2020-10-26 15:16:34 +00:00
|
|
|
set meta (
|
|
|
|
curl -SsLG "http://cn.bing.com/dict/search" --data-urlencode "q=$argv" | \
|
|
|
|
string match -r '<meta name="description" content="必应词典为您提供.+的释义,(.+?)" />'
|
|
|
|
)
|
|
|
|
set trans (string replace -ra '\W(?=(\w+\.|网络释义:))' \n $meta[2])
|
|
|
|
string join \n $trans
|
|
|
|
end
|
|
|
|
|
|
|
|
# pronounciation
|
|
|
|
function dp
|
|
|
|
set play afplay
|
|
|
|
if not which $play 2>/dev/null
|
|
|
|
set play ffplay -nodisp -autoexit
|
|
|
|
end
|
|
|
|
wget -O /tmp/sound.mp3 "http://dict.youdao.com/dictvoice?audio=$argv[1]&type=1" &>/dev/null
|
|
|
|
and eval $play /tmp/sound.mp3 1>/dev/null 2>/dev/null
|
2020-04-27 06:47:36 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function clean-taobao-link
|
2020-10-26 15:16:34 +00:00
|
|
|
echo "$argv" | sed 's/^\(.*\)?\(.*&\)\?\(id=[^&]\+\).*$/\1?\3/g' | xsel -sb
|
2020-04-27 06:47:36 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# for WSL
|
|
|
|
function sync-ssh-config
|
2020-10-26 15:16:34 +00:00
|
|
|
# sshconfig has a restricted file permission requirement which normally hard to
|
|
|
|
# be met on Window (i.e., syncing your config by Nextcloud on drive D).
|
|
|
|
# this function pours contents of files within ~/.ssh/config.d to ~/.ssh/config
|
|
|
|
if test -d ~/.ssh/config.d
|
|
|
|
rm -rf ~/.ssh/config
|
|
|
|
for cfg in (ls ~/.ssh/config.d)
|
|
|
|
cat ~/.ssh/config.d/$cfg >> ~/.ssh/config
|
|
|
|
end
|
|
|
|
chmod 600 ~/.ssh/config
|
2020-04-27 06:47:36 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function swap-caps-esc
|
2020-10-26 15:16:34 +00:00
|
|
|
setxkbmap -option caps:swapescape
|
2020-04-27 06:47:36 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function caps-to-grave
|
2020-10-26 15:16:34 +00:00
|
|
|
xmodmap -e "clear Lock"
|
|
|
|
xmodmap -e "keycode 66 = grave asciitilde"
|
2020-04-27 06:47:36 +00:00
|
|
|
end
|
|
|
|
|
2020-10-26 15:16:34 +00:00
|
|
|
# print out all colors with their index
|
2020-04-27 06:47:36 +00:00
|
|
|
function show-colors
|
2020-10-26 15:16:34 +00:00
|
|
|
bash -c '(x=`tput op` y=`printf %76s`;for i in {0..256};do o=00$i;echo -e ${o:${#o}-3:3} `tput setaf $i;tput setab $i`${y// /=}$x;done)'
|
2020-04-27 06:47:36 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# auto startx
|
2020-10-26 15:16:34 +00:00
|
|
|
if test -z "$STARTED" -a -z "$DISPLAY" -a -n "$XDG_VTNR" -a "$XDG_VTNR" -eq "1"
|
|
|
|
set -gx STARTED true
|
|
|
|
startx
|
2020-04-27 06:47:36 +00:00
|
|
|
end
|
|
|
|
|
2020-10-28 17:17:35 +00:00
|
|
|
if status is-interactive
|
|
|
|
alias k="kubectl"
|
|
|
|
alias kcc="k config get-contexts"
|
|
|
|
alias kcu="k config use-context"
|
|
|
|
alias kgd="k get deployment"
|
|
|
|
alias ked="k edit deployment"
|
|
|
|
alias kgp="k get pod -o 'custom-columns=NAME:.metadata.name,IMG:.spec.containers[*].image,STATUS:.status.phase'"
|
|
|
|
alias kl="k logs -f --all-containers"
|
|
|
|
alias issh='ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null"'
|
|
|
|
alias iscp='scp -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null"'
|
|
|
|
cd $last_pwd
|
2020-10-29 06:00:04 +00:00
|
|
|
source-file-if-exists /usr/share/autojump/autojump.fish
|
|
|
|
source-file-if-exists /usr/local/share/autojump/autojump.fish
|
|
|
|
source-file-if-exists ~/.config/fish/virtualfish
|
|
|
|
source-file-if-exists ~/.profile.fish
|
2020-10-28 17:17:35 +00:00
|
|
|
source-file-if-exists ~/.profile.fish
|
|
|
|
end
|
2020-04-27 06:47:36 +00:00
|
|
|
|