fzf alias to cd and open a file with vi
This commit is contained in:
parent
be91605bfe
commit
e42eead94e
20
zshrc
20
zshrc
|
@ -49,6 +49,8 @@ else
|
||||||
alias lr='ls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/ /'\'' -e '\''s/-/|/'\'''
|
alias lr='ls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/ /'\'' -e '\''s/-/|/'\'''
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
alias d='docker'
|
||||||
|
|
||||||
# sudo
|
# sudo
|
||||||
## Please consider using "Defaults env_keep+=HOME" configuration in sudoers {{{
|
## Please consider using "Defaults env_keep+=HOME" configuration in sudoers {{{
|
||||||
### This is Ubuntu default behaviour.
|
### This is Ubuntu default behaviour.
|
||||||
|
@ -1233,6 +1235,24 @@ cf() {
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# v - fuzzy open with vi from current directory
|
||||||
|
# cd into the directory of the selected file
|
||||||
|
# open the selected file with vi
|
||||||
|
v() {
|
||||||
|
local files
|
||||||
|
|
||||||
|
files=$(find ${1:-.} -path '*/\.*' -prune \
|
||||||
|
-o -print 2> /dev/null | fzf +m) &&
|
||||||
|
|
||||||
|
if [[ -n $files ]]
|
||||||
|
then
|
||||||
|
dir=$(dirname "${files}")
|
||||||
|
cd "${dir}"
|
||||||
|
file=$(basename "${files}")
|
||||||
|
vi -- "${file}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# zsh-syntax-highlighting {{{
|
# zsh-syntax-highlighting {{{
|
||||||
## Activate if plugin is available
|
## Activate if plugin is available
|
||||||
[ -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