Skip to content

Instantly share code, notes, and snippets.

@chrisnorris
Forked from rumpelsepp/fcd.fish
Last active October 17, 2024 12:28
Show Gist options
  • Save chrisnorris/fe57c7855fd87a2636999edf1d4d735b to your computer and use it in GitHub Desktop.
Save chrisnorris/fe57c7855fd87a2636999edf1d4d735b to your computer and use it in GitHub Desktop.

Revisions

  1. chrisnorris revised this gist Oct 8, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fcd.fish
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    function -d "Fuzzy change directory" fcd
    function fcd --description "Fuzzy change directory"
    if set -q argv[1]
    set searchdir $argv[1]
    else
  2. Stefan Tatschner created this gist Mar 20, 2016.
    19 changes: 19 additions & 0 deletions fcd.fish
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    function -d "Fuzzy change directory" fcd
    if set -q argv[1]
    set searchdir $argv[1]
    else
    set searchdir $HOME
    end

    # https://github.com/fish-shell/fish-shell/issues/1362
    set -l tmpfile (mktemp)
    find $searchdir \( ! -regex '.*/\..*' \) ! -name __pycache__ -type d | fzf > $tmpfile
    set -l destdir (cat $tmpfile)
    rm -f $tmpfile

    if test -z "$destdir"
    return 1
    end

    cd $destdir
    end