helper-scripts/zellij-ps.fish

27 lines
803 B
Fish
Raw Normal View History

2024-03-20 05:57:37 +01:00
#!/usr/bin/env fish
# This is a small zellij project switcher
#
# For defining project folders export the variable $PROJECT_FOLDERS in your favourite shell
# The folders should by delimited by a :
# Fish example: set -x PROJECT_FOLDERS ~/projects:~/Downloads/My Folder
2024-03-20 05:57:37 +01:00
set -l IFS ':'
set folders (string split ':' -- $PROJECT_FOLDERS | string replace -r '^~' $HOME)
echo $folders
2024-03-20 05:57:37 +01:00
if count $argv > 1
set selected $argv[1]
else
set selected (fd --type d --max-depth 1 . $folders | fzf)
end
set selected_name (basename "$selected" | tr . _)
set zellij_running (pgrep -c zellij)
if test -n "$ZELLIJ_SESSION_NAME"
echo -e "You are in a Zellij Session!\nPlease use the session manager to switch sessions.">&2
else
cd $selected; zellij --layout prog attach -c $selected_name options
end