Last active
August 4, 2025 20:42
-
-
Save nerflad/173b228ab269447b8bb1464ddafa7312 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 x --wraps=exit --description 'alias x exit' | |
| set -l currentSession (ps aux | grep (zellij list-sessions | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" | grep current 2>/dev/null | awk -F' ' '{print $1}') 2>/dev/null | grep -v grep 2>/dev/null | awk -F' ' '{print $2}') | |
| set -l zellijAttach (pgrep -f "zellij attach") | |
| set -l zellijMain (pgrep -f "zellij" | head -n1) | |
| [ -n "$zellijAttach" ] && kill -15 "$zellijAttach" && return 0 | |
| #↓ else: haven't detached from session yet | |
| if contains "$currentSession" (pgrep zellij) | |
| kill -15 "$zellijMain" | |
| return 0 | |
| end | |
| if ! contains (ps -o ppid -p $fish_pid | sed 's/^ //g') (pgrep zellij) | |
| exit $argv | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment