Files
bash-it/plugins/available/fasd.plugin.bash
Tomas Slusny 5c69d79810 Recognize fasd when sourced
According to fasd README, fasd can be also used by sourcing it and not only by including it into path. This patch will ensure that fasd will be properly recognized, even when it is sourced and not included in path.
2016-09-07 10:17:40 +02:00

35 lines
1.0 KiB
Bash
Executable File

cite about-plugin
about-plugin 'initialize fasd (see https://github.com/clvv/fasd)'
__init_fasd() {
command -v fasd &> /dev/null
if [ $? -eq 1 ]; then
echo -e "You must install fasd before you can use this plugin"
echo -e "See: https://github.com/clvv/fasd"
else
eval "$(fasd --init posix-alias)"
# Note, this is a custom bash-hook to ensure that the last exit status
# is maintained even while this hook is in place. This code can be
# removed once PR #72 is merged into fasd.
#
# See: https://github.com/clvv/fasd/pull/72
_fasd_prompt_func() {
local _exit_code="$?"
eval "fasd --proc $(fasd --sanitize $(history 1 | \
sed "s/^[ ]*[0-9]*[ ]*//"))" >> "/dev/null" 2>&1
return $_exit_code
}
# add bash hook
case $PROMPT_COMMAND in
*_fasd_prompt_func*) ;;
"") PROMPT_COMMAND="_fasd_prompt_func";;
*) PROMPT_COMMAND="_fasd_prompt_func;$PROMPT_COMMAND";;
esac
eval "$(fasd --init bash-ccomp bash-ccomp-install)"
fi
}
__init_fasd