Skip to content

Instantly share code, notes, and snippets.

@alexrutar
Last active August 21, 2023 17:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexrutar/c8fe3ea25b7807f32d2c85173816d0ae to your computer and use it in GitHub Desktop.
Save alexrutar/c8fe3ea25b7807f32d2c85173816d0ae to your computer and use it in GitHub Desktop.
Change Directory with Search

Often, it is useful to jump to search for a directory and automatically change to it. By comining the fd and fzf tools, we can create a simple cd variant:

function fcd
    set --local base "$HOME"
    set --local target (fd --base-directory $base --type directory | fzf --query "$argv")
    cd $base/$target
end

Call with fcd $query where $query is an optional string to initialize the search.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment