~kris/dots

srice

ref: f5fc91419850ee5f2652bdce0dcc214de18b4a22 srice/.local/bin/proj -rwxr-xr-x 583 bytes
f5fc9141 — Kris Yotam add wallpapermenu script (was untracked); auto-detect output so cw works on any machine 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