I've stumbled on a bug in the garuda-fish-config package having to do with the "done.fish" script, which notifies you when long running shell processes are complete.
When a long running process is executed within a tmux session, the notification occurs as expected but the process exits with an error message about usage of ps.
$ sleep 11
error: process ID out of range
Usage:
ps [options]
Try 'ps --help <simple|list|output|threads|misc|all>'
or 'ps --help <s|l|o|t|m|a>'
for additional help text.
For more details see ps(1).
basename: missing operand
Try 'basename --help' for more information.
error: process ID out of range
Usage:
ps [options]
Try 'ps --help <simple|list|output|threads|misc|all>'
or 'ps --help <s|l|o|t|m|a>'
for additional help text.
For more details see ps(1).
I've traced this down to the __done_is_tmux_window_active function in the file /etc/skel/.config/fish/conf.d/done.fish installed by garuda-fish-config. I would file an issue against that repo directly, but I can't find it. The gitlab project here is outdated and doesn't have this script: Abhishek Anil Deshmukh / garuda-fish-config · GitLab.
On a side note, that error indicates trying to ps -p either an insanely large integer (unlikely) or 0, and I suspect the loop ends up requesting ppid of process 1 thereby getting zero as result.
Just speculation here, I did not test.
By the way:
Maybe work around (again, untested):
function __done_is_tmux_window_active
set -q fish_pid; or set -l fish_pid %self
# find the outermost process within tmux
# ppid != "tmux" -> pid = ppid
# ppid == "tmux" -> break
set tmux_fish_pid $fish_pid
while set tmux_fish_ppid (ps -o ppid= -p $tmux_fish_pid | string trim)
and ! string match -qr '^0?$' $tmux_fish_ppid # <==
and ! string match -q "tmux*" (basename (ps -o command= -p $tmux_fish_ppid))
set tmux_fish_pid $tmux_fish_ppid
end
string match -qr '^0?$' $tmux_fish_ppid; and return 1 # <==
# tmux session attached and window is active -> no notification
# all other combinations -> send notification
tmux list-panes -a -F "#{session_attached} #{window_active} #{pane_pid}" | string match -q "1 1 $tmux_fish_pid"
end
I think it would be better to rearrange the loop somewhat, but cannot test now so I keep it simple.
I tested the updated function in your workaround. It is partially effective. The error message no longer occurs.
The function still causes a notification to be sent, regardless of whether the tmux window is active. This was also true of the original/broken function, but based on the function comments is clearly not the desired behavior.
I'll see if I can tinker with this further soon if no one else comes up with a solution.
If you come up with a solution, there is nothing stopping us from patching the source accordingly. So let me know about it please although, a PR would be best