Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if which fasd >/dev/null; then
- # install fasd hooks and basic aliases in the shell
- eval "$(fasd --init auto)"
- # if there is fzf available use it to search fasd results
- if which fzf >/dev/null; then
- alias v >/dev/null && unalias v
- alias vd >/dev/null && unalias vd
- alias z >/dev/null && unalias z
- # edit given file or search in recently used files
- function v {
- local file
- # if arg1 is a path to existing file then simply open it in the editor
- test -e "$1" && $EDITOR "$@" && return
- # else use fasd and fzf to search for recent files
- file="$(fasd -Rfl "$*" | fzf -1 -0 --no-sort +m)" && $EDITOR "${file}" || $EDITOR "$@"
- }
- # cd into the directory containing a recently used file
- function vd {
- local dir
- local file
- file="$(fasd -Rfl "$*" | fzf -1 -0 --no-sort +m)" && dir=$(dirname "$file") && cd "$dir"
- }
- # cd into given dir or search in recently used dirs
- function z {
- [ $# -eq 1 ] && test -d "$1" && cd "$1" && return
- local dir
- dir="$(fasd -Rdl "$*" | fzf -1 -0 --no-sort +m)" && cd "${dir}" || return 1
- }
- fi
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement