grace/dots
dotfiles/nix configs
git clone https://git.gae.moe/grace/dots
08de973
main
1set -l choice( 2begin 3printf '%s\n' $argv 4zoxide query--list | while read -l directory 5printf 'directory\t%s\n' " $directory " 6end 7end | while read -l line 8set -l entry( string split\t --" $line " ) 9switch " $entry [ 1 ] " 10case workspace 11set entry[2]( set_color magenta) " $entry [ 2 ] " ( set_color normal) 12case ssh 13set entry[2]( set_color cyan) " $entry [ 2 ] " ( set_color normal) 14case directory 15set entry[2]( set_color green) " $entry [ 2 ] " ( set_color normal) 16end 17string join\t --$entry 18end | 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 28set -l entry( string split\t --" $choice [ 3 ] " ) 29set name" $entry [ 2 ] " 30switch " $entry [ 1 ] " 31case ssh 32set host" $entry [ 3 ] " 33case directory 34set cwd" $entry [ 2 ] " 35set name( path basename --" $cwd " ) 36end 37else 38set -l directory( string replace-r '^~/' " $HOME /" --" $name " ) 39if test -d " $directory " 40set cwd( path resolve --" $directory " ) 41set name( path basename --" $cwd " ) 42else if string match-q '*:*' --" $name " 43set -l parts( string split-m 1 : --" $name " ) 44test -n " $parts [ 1 ] " ; and test -n " $parts [ 2 ] " ; or exit 0 45set host" $parts [ 2 ] " 46for candidatein $argv 47set -l entry( string split\t --" $candidate " ) 48if test " $entry [ 1 ] " = ssh; and test " $entry [ 2 ] " =" $host " 49set host" $entry [ 3 ] " 50break 51end 52end 53end 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