From 0b1a6153f95485c70b695a54af7347b049ac48ed Mon Sep 17 00:00:00 2001 From: Erwin Jansen Date: Thu, 26 Jul 2018 09:36:30 -0700 Subject: [PATCH] plugins: Add fasd plugin Fasd offers quick access to files and directories. It is inspired by tools like autojump, z and v. Fasd keeps track of files and directories you have accessed, so that you can quickly reference them in the command line This plugin sets up fasd to use safe_command_prompt handling of oh-my-bash to avoid conflicts with fasd's normal bash prompt handling. More information about fasd can be found here: https://github.com/clvv/fasd. --- plugins/fasd/fasd.plugin.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 plugins/fasd/fasd.plugin.sh diff --git a/plugins/fasd/fasd.plugin.sh b/plugins/fasd/fasd.plugin.sh new file mode 100644 index 0000000..42590ba --- /dev/null +++ b/plugins/fasd/fasd.plugin.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env sh + +# Initialize fasd, without setting up the prompt hook, which +# we want to be handled by oh-my-bash. + +_fasd_prompt_func() { + [ -z "$_FASD_SINK" ] && _FASD_SINK=/dev/null + eval "fasd --proc \$(fasd --sanitize \$(history 1 | \\ + sed "s/^[ ]*[0-9]*[ ]*//"))" >> "$_FASD_SINK" 2>&1 +} + +function _install_fasd() { + type fasd >/dev/null 2>&1 + if [ "$?" == "0" ]; then + eval "$(fasd --init posix-alias bash-ccomp bash-ccomp-install)" + _omb_util_add_prompt_command _fasd_prompt_func + else + echo "fasd not found, plugin not activated." + fi +} + + +_install_fasd