mirror of
https://github.com/DictXiong/dotfiles.git
synced 2024-11-24 09:17:02 +08:00
zshrc: key bindings and piv-agent (#27)
* piv-agent; macos key bindings; doll fix * ci: piv-agent
This commit is contained in:
parent
6e33fc0875
commit
3ce5a7ade8
57
.zshrc2
57
.zshrc2
|
@ -64,8 +64,7 @@ ANTIGEN_PLUGINS+=( \
|
||||||
"ufw" \
|
"ufw" \
|
||||||
"z" \
|
"z" \
|
||||||
)
|
)
|
||||||
for i in ${ANTIGEN_PLUGINS[*]}
|
for i in ${ANTIGEN_PLUGINS[*]}; do
|
||||||
do
|
|
||||||
if [[ -z $ANTIGEN_EXCLUDE || ! $i =~ $ANTIGEN_EXCLUDE ]]; then
|
if [[ -z $ANTIGEN_EXCLUDE || ! $i =~ $ANTIGEN_EXCLUDE ]]; then
|
||||||
antigen bundle $i
|
antigen bundle $i
|
||||||
fi
|
fi
|
||||||
|
@ -89,22 +88,51 @@ alias "se"='sudo -sE'
|
||||||
alias "pbd"='ping baidu.com'
|
alias "pbd"='ping baidu.com'
|
||||||
alias "p114"='ping 114.114.114.114'
|
alias "p114"='ping 114.114.114.114'
|
||||||
alias "p666"='ping6 2001:da8::666'
|
alias "p666"='ping6 2001:da8::666'
|
||||||
sibd() {ssh -p 12022 root@$1${1:+.}ibd.ink}
|
sibd() { ssh -p 12022 root@$1${1:+.}ibd.ink }
|
||||||
sob() {ssh -p 24022 root@$1${1:+.}ob.ac.cn}
|
sob() { ssh -p 24022 root@$1${1:+.}ob.ac.cn }
|
||||||
case $(bash "$DOTFILES/tools/common.sh" get_os_type) in
|
case $(bash "$DOTFILES/tools/common.sh" get_os_type) in
|
||||||
macos ) alias l='ls -lAGh -D "%y-%m-%d %H:%M"' ;;
|
macos ) alias l='ls -lAGh -D "%y-%m-%d %H:%M"' ;;
|
||||||
* ) alias l='ls -lAGh --time-style="+%y-%m-%d %H:%M"' ;;
|
* ) alias l='ls -lAGh --time-style="+%y-%m-%d %H:%M"' ;;
|
||||||
esac
|
esac
|
||||||
|
piv-agent()
|
||||||
|
{
|
||||||
|
# they are: ubuntu, macos, respectively
|
||||||
|
local SO_PATHS=( "/usr/lib64/opensc-pkcs11.so" "/usr/local/lib/opensc-pkcs11.so" )
|
||||||
|
for i in ${SO_PATHS[*]}; do
|
||||||
|
if [[ -f "$i" ]]; then
|
||||||
|
eval $(ssh-agent -P "$i")
|
||||||
|
ssh-add -s "$i"
|
||||||
|
echo "now available keys:"
|
||||||
|
ssh-add -l
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "opensc-pkcs11.so not found"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
# key bindings
|
# key bindings
|
||||||
bindkey "^b" beginning-of-line
|
bindkey "^b" beginning-of-line # ctrl+b
|
||||||
bindkey "^e" end-of-line
|
bindkey "\eOH" beginning-of-line
|
||||||
bindkey "^[[H" beginning-of-line
|
bindkey "\e[H" beginning-of-line # home; termius
|
||||||
bindkey "^[[F" end-of-line
|
bindkey "\e[1~" beginning-of-line
|
||||||
bindkey "^[[1~" beginning-of-line
|
|
||||||
bindkey "^[[4~" end-of-line
|
bindkey "^e" end-of-line # ctrl+e
|
||||||
bindkey "^[OH" beginning-of-line
|
bindkey "\eOF" end-of-line
|
||||||
bindkey "^[OF" end-of-line
|
bindkey "\e[F" end-of-line # end; termius
|
||||||
|
bindkey "\e[4~" end-of-line
|
||||||
|
|
||||||
|
bindkey "\ef" forward-word # alt+f
|
||||||
|
bindkey "\e[5C" forward-word
|
||||||
|
bindkey "\e\e[C" forward-word # alt+right_arrow; iterm2
|
||||||
|
bindkey "\e[1;5C" forward-word # alt+right_arrow; termius
|
||||||
|
|
||||||
|
bindkey "\eb" backward-word # alt+e
|
||||||
|
bindkey "\e[5D" backward-word
|
||||||
|
bindkey "\e\e[D" backward-word # alt+left_arrow; iterm2
|
||||||
|
bindkey "\e[1;5D" backward-word # alt+left_arrow; termius
|
||||||
|
|
||||||
|
bindkey "\ed" delete-char # alt+d
|
||||||
|
|
||||||
# dfs
|
# dfs
|
||||||
dfs()
|
dfs()
|
||||||
|
@ -115,7 +143,7 @@ dfs()
|
||||||
cd "$DOTFILES"
|
cd "$DOTFILES"
|
||||||
git fetch --all
|
git fetch --all
|
||||||
ref=$(git symbolic-ref --short HEAD 2> /dev/null) || ref=$(git rev-parse --short HEAD 2> /dev/null) || return 0
|
ref=$(git symbolic-ref --short HEAD 2> /dev/null) || ref=$(git rev-parse --short HEAD 2> /dev/null) || return 0
|
||||||
for b in $(git for-each-ref refs/heads --format='%(refname)') ; do git checkout ${b#refs/heads/} ; git pull --ff-only ; done
|
for i in $(git for-each-ref refs/heads --format='%(refname)') ; do git checkout ${i#refs/heads/} ; git pull --ff-only ; done
|
||||||
git checkout -c advice.detachedHead=false $ref)
|
git checkout -c advice.detachedHead=false $ref)
|
||||||
;;
|
;;
|
||||||
version ) (cd "$DOTFILES" && git rev-parse HEAD) ;;
|
version ) (cd "$DOTFILES" && git rev-parse HEAD) ;;
|
||||||
|
@ -132,3 +160,6 @@ dfs()
|
||||||
* ) echo "unknown command \"$1\". available: update, force-update, version, reset, cd, log" ;;
|
* ) echo "unknown command \"$1\". available: update, force-update, version, reset, cd, log" ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# clean
|
||||||
|
unset i
|
||||||
|
|
|
@ -23,7 +23,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$CONTAINER" ]]; then
|
if [[ -z "$CONTAINER" ]]; then
|
||||||
fmt_error "container not found"
|
fmt_fatal "container not found"
|
||||||
else
|
else
|
||||||
echo "--> ${CONTAINER_META[@]}"
|
echo "--> ${CONTAINER_META[@]}"
|
||||||
$SUDO docker exec -it $CONTAINER sh -c 'if [ -x "$(command -v zsh)" ]; then echo "--> zsh"; zsh; elif [ -x "$(command -v bash)" ]; then echo "--> bash"; bash; else echo "--> sh"; sh; fi'
|
$SUDO docker exec -it $CONTAINER sh -c 'if [ -x "$(command -v zsh)" ]; then echo "--> zsh"; zsh; elif [ -x "$(command -v bash)" ]; then echo "--> bash"; bash; else echo "--> sh"; sh; fi'
|
||||||
|
|
|
@ -18,8 +18,8 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$IMAGE" ]]; then
|
if [[ -z "$IMAGE" ]]; then
|
||||||
fmt_error "image not found"
|
fmt_fatal "image not found"
|
||||||
else
|
else
|
||||||
echo "--> ${IMAGE_META[@]}"
|
echo "--> ${IMAGE_META[@]}"
|
||||||
echo $SUDO docker run -itd $IMAGE sh
|
$SUDO docker run -itd $IMAGE sh
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -26,7 +26,9 @@ tools/common.sh get_os_type
|
||||||
tools/common.sh get_linux_dist
|
tools/common.sh get_linux_dist
|
||||||
|
|
||||||
# check alias
|
# check alias
|
||||||
alias p114 > /dev/null
|
alias p114
|
||||||
|
sibd || which sibd
|
||||||
|
piv-agent || which piv-agent
|
||||||
|
|
||||||
# check update
|
# check update
|
||||||
DFS_VERSION=`dfs version`
|
DFS_VERSION=`dfs version`
|
||||||
|
|
Loading…
Reference in New Issue
Block a user