diff options
author | Thomas Voss <mail@thomasvoss.com> | 2023-11-05 19:21:51 +0100 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2023-11-05 19:21:51 +0100 |
commit | a67bc5647ede4433ffe6dfdeac36dc6fc716e971 (patch) | |
tree | 7d76ded4bce8a746844c76e8e514a0c9adfb51be /.bashrc | |
parent | 4d4fa986d7ada824ef91ae9074ab4e7cf84bb754 (diff) |
bash: Add ‘jc’ to mimic ‘jr’ but for ~/.config
Diffstat (limited to '.bashrc')
-rw-r--r-- | .bashrc | 25 |
1 files changed, 19 insertions, 6 deletions
@@ -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" |