diff options
Diffstat (limited to '.bashrc')
| -rw-r--r-- | .bashrc | 44 |
1 files changed, 44 insertions, 0 deletions
@@ -22,6 +22,21 @@ if [[ "$TERM" = "dumb" ]]; then export PS1="> " fi +# Add to path cleanly +local_pathmunge () { + case ":${PATH}:" in + *:"$1":*) + ;; + *) + if [ "$2" = "after" ] ; then + PATH=$PATH:$1 + else + PATH=$1:$PATH + fi + esac +} +local_pathmunge ~/usr/local/bin + # Change to the correct sibling of a parent directory cd_parent_sibling () { @@ -110,3 +125,32 @@ ef() emacsclient -n -c "$@" fi } + +# Source first available file in list +source_first() +{ + for x in $*; do + [ -f $x ] && source $x && break + done +} + +# fasd: Jump to directory or use FZF +j() { + [ $# -gt 0 ] && fasd_cd -d "$*" && return + local dir + dir=$(fasd -Rdl "$1" | fzf -1 -0 --no-sort +m) && cd "${dir}" || return 1 +} + +# Set up command-line key bindings +case "$-" in + *i*) + # Interactive shells + # Set up fzf and fasd + source_first /usr/share/fzf/shell/key-bindings.bash ~/.fzf.bash + eval "$(~/usr/local/bin/fasd --init auto)" + complete -d j + ;; + *) + # Non-interactive shells + ;; +esac |
