From 745e676af25657568be3b83cfafd56a833e46442 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Wed, 20 Apr 2022 15:49:53 +0800 Subject: Update --- tools/init/load-settings.sh | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) (limited to 'tools') diff --git a/tools/init/load-settings.sh b/tools/init/load-settings.sh index f60c7d4..bfe643b 100755 --- a/tools/init/load-settings.sh +++ b/tools/init/load-settings.sh @@ -7,22 +7,31 @@ source $SETTING_DIR/alias [[ -d $SETTING_DIR/private ]] && for f in $SETTING_DIR/private/*; do source $f; done # Config shell -shell=$(cat /proc/$$/cmdline | tr -d '\0') -case $shell in - *zsh*) - setopt extended_glob - fpath=($SETTING_DIR/zsh $fpath) - compinit - autoload -U deer - zle -N deer - bindkey '\ek' deer - alias history='history -i' - ;; - *bash*) - shopt -s extglob - HISTTIMEFORMAT='%Y-%m-%d %T ' - ;; -esac +SHELL=$(cat /proc/$$/cmdline | tr -d '\0' | xargs basename) + +# fzf +if which fzf &>/dev/null; then + [ -f ~/.fzf.$SHELL ] && source ~/.fzf.$SHELL + fzf_preview() { fzf --preview 'cat {}'; } +fi + +if [[ $SHELL == zsh ]]; then + setopt extended_glob + fpath=($SETTING_DIR/zsh $fpath) + compinit + autoload -U deer + zle -N deer + bindkey '\ek' deer + alias history='history -i' + + #zle -N fzf_preview + bindkey -s "^I" 'fzf_preview ' +elif [[ $SHELL == bash ]]; then + shopt -s extglob + HISTTIMEFORMAT='%Y-%m-%d %T ' + + bind -x '"\C-i": "fzf_preview"' +fi # Add custom scripts into PATH BIN_DIR=$HOME/bin -- cgit v1.2.3-70-g09d2