From a67bc5647ede4433ffe6dfdeac36dc6fc716e971 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sun, 5 Nov 2023 19:21:51 +0100 Subject: bash: Add ‘jc’ to mimic ‘jr’ but for ~/.config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bashrc | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/.bashrc b/.bashrc index 5cef36e..93fcbd4 100644 --- a/.bashrc +++ b/.bashrc @@ -2,13 +2,26 @@ [[ $- != *i* ]] && return [[ -f /etc/bashrc ]] && . /etc/bashrc -function jr { - local dir=` - find "$REPODIR" -maxdepth 2 -path "$REPODIR/*/*" -printf '%P\n' \ +function __dir_search { + local qry="$1" + local base="$2" + shift 2 + + local dir=$( + find "$base" "$@" -printf '%P\n' \ + | sed 1i. \ | sort -r \ - | fzf -q "$1" - ` - [[ -n "$dir" ]] && cd "$REPODIR/$dir" + | fzf -q "$qry" + ) + [[ -n "$dir" ]] && pushd "$base/$dir" +} + +function jr { + __dir_search "$1" "$REPODIR" -mindepth 2 -maxdepth 2 +} + +function jc { + __dir_search "$1" "$XDG_CONFIG_HOME" -maxdepth 1 -type d } export BROWSER="firefox" -- cgit v1.2.3