dotfiles

personal configuration files and scripts
git clone https://tongong.net/git/dotfiles.git
Log | Files | Refs | README

fcd (505B)


      1 #!/usr/bin/env sh
      2 # gives a fuzzy-finding menu to switch to common directories
      3 
      4 # this script has to be sourced to make the cd run outside of a subshell
      5 # put this in your bashrc to source automatically
      6 # alias fcd=". fcd"
      7 
      8 INDEXFILE=~/.config/fcd/index.txt
      9 
     10 chosen="$( (echo exit; cat "$INDEXFILE") | fzf --layout=reverse --height=40% \
     11     | sed -E "s/^~/\/home\/$(whoami)/")"
     12 
     13 [ -d "$chosen" ] && cd "$chosen"
     14 [ -f "$chosen" ] && cd "$(dirname $chosen)" && nvim "$chosen"
     15 
     16 unset INDEXFILE
     17 unset chosen