Last active
May 24, 2025 18:33
-
-
Save whynotavailable/8d9ed453170754455b8985622711a06f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function sesh | |
| # Init sesh file. | |
| if test "$argv[1]" = --list | |
| for s in $sesh | |
| if test -z "$s" | |
| continue | |
| end | |
| set parts (string split : $s) | |
| echo $parts[1] | |
| end | |
| end | |
| if test "$argv[1]" = --use | |
| if test -z "$argv[2]" | |
| echo "Missing Session Name" | |
| return | |
| end | |
| for s in $sesh | |
| set parts (string split : $s) | |
| if test "$parts[1]" = "$argv[2]" | |
| cd "$parts[2]" | |
| end | |
| end | |
| end | |
| if test "$argv[1]" = --init | |
| if test -z "$argv[2]" | |
| set ldir $(string split / $(pwd)) | |
| set key "$ldir[-1]" | |
| else | |
| set key "$argv[2]" | |
| end | |
| set -aUu sesh "$key:$(pwd)" | |
| end | |
| if test "$argv[1]" = --rmhere | |
| for i in (seq (count $sesh)) | |
| set parts (string split : $sesh[$i]) | |
| # Probs useless but I don't care | |
| set path (pwd) | |
| if test "$path" = "$parts[2]" | |
| set -e sesh[$i] | |
| return | |
| end | |
| end | |
| echo "Current path not in session" | |
| end | |
| end | |
| complete -c sesh -l init | |
| complete -c sesh -l use -ra "(sesh --list)" | |
| complete -c sesh -l list | |
| complete -c sesh -l rmhere |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment