~kris/dots

srice

ref: 75870dc6ce1e524c46a85157489f839161c9607c srice/.local/bin/proj -rwxr-xr-x 583 bytes
75870dc6 — Kris Yotam add cw symlink for wallpapermenu (short name matching its own docs) 3 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