~kris/dots

srice

ref: 178c9a25a484ead715392d50e21d03df486b8b41 srice/.local/bin/proj -rwxr-xr-x 583 bytes
178c9a25 — Kris Yotam conky: sync proper config from moirai (was the greenred variant) 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh
# proj -- fuzzy project switcher for ~/dev
# Usage: proj [query]
# Requires: fzf, eza

DEV_DIR="$HOME/dev"

if [ -n "$1" ]; then
    # direct match
    target="$DEV_DIR/$1"
    if [ -d "$target" ]; then
        cd "$target"
        echo "$target"
        exit 0
    fi
fi

# fuzzy select
dir=$(find "$DEV_DIR" -maxdepth 1 -type d | sort |
    sed "s|$DEV_DIR/||" | tail -n +2 |
    fzf --preview "eza --tree --icons --level=2 --color=always $DEV_DIR/{}" \
        --preview-window 'right:50%' \
        --query "${1:-}")

if [ -n "$dir" ]; then
    echo "$DEV_DIR/$dir"
fi