Load fzf at the end to avoir override.
This commit is contained in:
parent
704d83d30c
commit
102b8315ca
137
zshrc
137
zshrc
|
@ -704,69 +704,6 @@ function translate()
|
||||||
wget -U "Mozilla/5.0" -qO - "http://translate.google.com/translate_a/t?client=t&text=${1}&sl=${2}&tl=${3}" | sed 's/\[\[\[\"//' | cut -d \" -f 1
|
wget -U "Mozilla/5.0" -qO - "http://translate.google.com/translate_a/t?client=t&text=${1}&sl=${2}&tl=${3}" | sed 's/\[\[\[\"//' | cut -d \" -f 1
|
||||||
}
|
}
|
||||||
|
|
||||||
## fzf
|
|
||||||
if [ -d ~/.fzf ]; then
|
|
||||||
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
|
|
||||||
|
|
||||||
# ff - cd to selected directory (exclude hidden directories
|
|
||||||
ff() {
|
|
||||||
local dir
|
|
||||||
dir=$(find ${1:-.} -path '*/\.*' -prune \
|
|
||||||
-o -type d -print 2> /dev/null | fzf +m) &&
|
|
||||||
cd "$dir"
|
|
||||||
}
|
|
||||||
|
|
||||||
# ffh - hidden directories only
|
|
||||||
ffh() {
|
|
||||||
local dir
|
|
||||||
dir=$(find ${1:-.} -type d 2> /dev/null | fzf +m) && cd "$dir"
|
|
||||||
}
|
|
||||||
|
|
||||||
# ffa - all directories
|
|
||||||
|
|
||||||
# ffr - cd to selected parent directory
|
|
||||||
ffr() {
|
|
||||||
local declare dirs=()
|
|
||||||
get_parent_dirs() {
|
|
||||||
if [[ -d "${1}" ]]; then dirs+=("$1"); else return; fi
|
|
||||||
if [[ "${1}" == '/' ]]; then
|
|
||||||
for _dir in "${dirs[@]}"; do echo $_dir; done
|
|
||||||
else
|
|
||||||
get_parent_dirs $(dirname "$1")
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
local DIR=$(get_parent_dirs $(realpath "${1:-$PWD}") | fzf-tmux --tac)
|
|
||||||
cd "$DIR"
|
|
||||||
}
|
|
||||||
|
|
||||||
# fff - cd into the directory of the selected file
|
|
||||||
fff() {
|
|
||||||
local file
|
|
||||||
local dir
|
|
||||||
file=$(fzf +m -q "$1") && dir=$(dirname "$file") && cd "$dir"
|
|
||||||
}
|
|
||||||
|
|
||||||
# cf - fuzzy cd from anywhere
|
|
||||||
# ex: cf word1 word2 ... (even part of a file name)
|
|
||||||
# zsh autoload function
|
|
||||||
cf() {
|
|
||||||
local file
|
|
||||||
|
|
||||||
file="$(locate -Ai -0 $@ | grep -z -vE '~$' | fzf --read0 -0 -1)"
|
|
||||||
|
|
||||||
if [[ -n $file ]]
|
|
||||||
then
|
|
||||||
if [[ -d $file ]]
|
|
||||||
then
|
|
||||||
cd -- $file
|
|
||||||
else
|
|
||||||
cd -- ${file:h}
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
# 2. Prompt et définition des touches basiques #
|
# 2. Prompt et définition des touches basiques #
|
||||||
################################################
|
################################################
|
||||||
|
@ -1174,6 +1111,80 @@ setopt extendedglob
|
||||||
############### 9. Modules ################
|
############### 9. Modules ################
|
||||||
###########################################
|
###########################################
|
||||||
|
|
||||||
|
## fzf
|
||||||
|
if [ -d ~/.fzf ]; then
|
||||||
|
|
||||||
|
if [[ ! "$PATH" == *"${HOME}"/.fzf/bin* ]]; then
|
||||||
|
export PATH="$PATH:${HOME}/.fzf/bin"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Auto-completion
|
||||||
|
# ---------------
|
||||||
|
[[ $- == *i* ]] && source "${HOME}/.fzf/shell/completion.zsh" 2> /dev/null
|
||||||
|
|
||||||
|
# Key bindings
|
||||||
|
# ------------
|
||||||
|
source "${HOME}/.fzf/shell/key-bindings.zsh"
|
||||||
|
|
||||||
|
# ff - cd to selected directory (exclude hidden directories
|
||||||
|
ff() {
|
||||||
|
local dir
|
||||||
|
dir=$(find ${1:-.} -path '*/\.*' -prune \
|
||||||
|
-o -type d -print 2> /dev/null | fzf +m) &&
|
||||||
|
cd "$dir"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ffh - hidden directories only
|
||||||
|
ffh() {
|
||||||
|
local dir
|
||||||
|
dir=$(find ${1:-.} -type d 2> /dev/null | fzf +m) && cd "$dir"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ffa - all directories
|
||||||
|
|
||||||
|
# ffr - cd to selected parent directory
|
||||||
|
ffr() {
|
||||||
|
local declare dirs=()
|
||||||
|
get_parent_dirs() {
|
||||||
|
if [[ -d "${1}" ]]; then dirs+=("$1"); else return; fi
|
||||||
|
if [[ "${1}" == '/' ]]; then
|
||||||
|
for _dir in "${dirs[@]}"; do echo $_dir; done
|
||||||
|
else
|
||||||
|
get_parent_dirs $(dirname "$1")
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
local DIR=$(get_parent_dirs $(realpath "${1:-$PWD}") | fzf-tmux --tac)
|
||||||
|
cd "$DIR"
|
||||||
|
}
|
||||||
|
|
||||||
|
# fff - cd into the directory of the selected file
|
||||||
|
fff() {
|
||||||
|
local file
|
||||||
|
local dir
|
||||||
|
file=$(fzf +m -q "$1") && dir=$(dirname "$file") && cd "$dir"
|
||||||
|
}
|
||||||
|
|
||||||
|
# cf - fuzzy cd from anywhere
|
||||||
|
# ex: cf word1 word2 ... (even part of a file name)
|
||||||
|
# zsh autoload function
|
||||||
|
cf() {
|
||||||
|
local file
|
||||||
|
|
||||||
|
file="$(locate -Ai -0 $@ | grep -z -vE '~$' | fzf --read0 -0 -1)"
|
||||||
|
|
||||||
|
if [[ -n $file ]]
|
||||||
|
then
|
||||||
|
if [[ -d $file ]]
|
||||||
|
then
|
||||||
|
cd -- $file
|
||||||
|
else
|
||||||
|
cd -- ${file:h}
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
# zsh-syntax-highlighting
|
# zsh-syntax-highlighting
|
||||||
[ -f ~/repos/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ] && source ~/repos/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
[ -f ~/repos/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ] && source ~/repos/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue