From c747c6381fb800708984a4f3a1d54db664c3b64c Mon Sep 17 00:00:00 2001 From: Loic Nageleisen Date: Thu, 25 Aug 2022 12:13:21 +0200 Subject: [PATCH] Add fcd command --- shell/fzf | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/shell/fzf b/shell/fzf index e1101ad..0746547 100755 --- a/shell/fzf +++ b/shell/fzf @@ -6,6 +6,19 @@ if command -v fzf 2>&1 >/dev/null; then export FZF_DEFAULT_COMMAND='rg --files --no-ignore --hidden --follow --glob "!{.git,node_modules,vendor}/*"' export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" fi + + function fcd() { + local dir; + + while true; do + dir="$(ls -a1p | grep '/$' | grep -v '^./$' | fzf --height 40% --reverse --no-multi --preview 'pwd' --preview-window=up,1,border-none --no-info)" + if [[ -z "${dir}" ]]; then + break + else + cd "${dir}" + fi + done + } fi # vim: ft=bash