grace/dots

dotfiles/nix configs

git clone https://git.gae.moe/grace/dots

Grace Yoderflake rewrite + a bunch\ni keep holding onto changes forever this is not how you use vcs08de973

main
2.1 KiB61 linesraw
1set -l choice (
2    begin
3        printf '%s\n' $argv
4        zoxide query --list | while read -l directory
5            printf 'directory\t%s\n' "$directory"
6        end
7    end | while read -l line
8        set -l entry (string split \t -- "$line")
9        switch "$entry[1]"
10            case workspace
11                set entry[2] (set_color magenta)"$entry[2]"(set_color normal)
12            case ssh
13                set entry[2] (set_color cyan)"$entry[2]"(set_color normal)
14            case directory
15                set entry[2] (set_color green)"$entry[2]"(set_color normal)
16        end
17        string join \t -- $entry
18    end | fzf --ansi --no-sort --delimiter=\t --with-nth=2 --print-query --expect=enter,alt-enter \
19        --prompt='Workspace> ' --header='Enter: select or create · Alt+Enter: force new workspace'
20)
21or exit 0
22
23set -l name "$choice[1]"
24set -l cwd ''
25set -l host ''
26
27if test "$choice[2]" != alt-enter; and test (count $choice) -ge 3
28    set -l entry (string split \t -- "$choice[3]")
29    set name "$entry[2]"
30    switch "$entry[1]"
31        case ssh
32            set host "$entry[3]"
33        case directory
34            set cwd "$entry[2]"
35            set name (path basename -- "$cwd")
36    end
37else
38    set -l directory (string replace -r '^~/' "$HOME/" -- "$name")
39    if test -d "$directory"
40        set cwd (path resolve -- "$directory")
41        set name (path basename -- "$cwd")
42    else if string match -q '*:*' -- "$name"
43        set -l parts (string split -m 1 : -- "$name")
44        test -n "$parts[1]"; and test -n "$parts[2]"; or exit 0
45        set host "$parts[2]"
46        for candidate in $argv
47            set -l entry (string split \t -- "$candidate")
48            if test "$entry[1]" = ssh; and test "$entry[2]" = "$host"
49                set host "$entry[3]"
50                break
51            end
52        end
53    end
54end
55
56test -n "$name"; or exit 0
57set -l target (jq -cn --arg name "$name" --arg cwd "$cwd" --arg host "$host" \
58    '{name: $name, cwd: $cwd, host: $host}' | base64 | string join '')
59printf '\e]1337;SetUserVar=workspace_picker=%s\a' "$target"
60# Keep the picker pane alive until WezTerm handles the selection and closes it.
61read -l ignored