mirror of
https://github.com/dcarrillo/prezto.git
synced 2024-11-01 07:21:12 +00:00
948d9b3aa5
Fixes #1122
55 lines
1.1 KiB
Bash
55 lines
1.1 KiB
Bash
#
|
|
# Maintains a frequently used file and directory list for fast access.
|
|
#
|
|
# Authors:
|
|
# Wei Dai <x@wei23.net>
|
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
|
#
|
|
|
|
# Load dependencies.
|
|
pmodload 'editor'
|
|
|
|
# If the command doesn't exist externally, we need to fall back to the bundled
|
|
# submodule.
|
|
if (( ! $+commands[fasd] )); then
|
|
source "${0:h}/external/fasd" || return 1
|
|
fi
|
|
|
|
#
|
|
# Initialization
|
|
#
|
|
|
|
cache_file="${TMPDIR:-/tmp}/prezto-fasd-cache.$UID.zsh"
|
|
if [[ "${commands[fasd]}" -nt "$cache_file" || ! -s "$cache_file" ]]; then
|
|
# Set the base init arguments.
|
|
init_args=(zsh-hook)
|
|
|
|
# Set fasd completion init arguments, if applicable.
|
|
if zstyle -t ':prezto:module:completion' loaded; then
|
|
init_args+=(zsh-ccomp zsh-ccomp-install zsh-wcomp zsh-wcomp-install)
|
|
fi
|
|
|
|
# Cache init code.
|
|
fasd --init "$init_args[@]" >! "$cache_file" 2> /dev/null
|
|
fi
|
|
|
|
source "$cache_file"
|
|
|
|
unset cache_file init_args
|
|
|
|
function fasd_cd {
|
|
local fasd_ret="$(fasd -d "$@")"
|
|
if [[ -d "$fasd_ret" ]]; then
|
|
cd "$fasd_ret"
|
|
else
|
|
print "$fasd_ret"
|
|
fi
|
|
}
|
|
|
|
#
|
|
# Aliases
|
|
#
|
|
|
|
# Changes the current working directory interactively.
|
|
alias j='fasd_cd -i'
|