Skip to content

Instantly share code, notes, and snippets.

@whynotavailable
Last active May 24, 2025 18:33
Show Gist options
  • Save whynotavailable/8d9ed453170754455b8985622711a06f to your computer and use it in GitHub Desktop.
Save whynotavailable/8d9ed453170754455b8985622711a06f to your computer and use it in GitHub Desktop.
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