diff options
author | Linnnus <[email protected]> | 2023-11-07 17:37:37 +0100 |
---|---|---|
committer | Linnnus <[email protected]> | 2023-11-07 17:37:37 +0100 |
commit | 3824d4d797d39bd6f2dee3655027a79713ef400c (patch) | |
tree | 617a3e9294573604aaedc04c72973639cc919954 /pkgs/watch-while/watch-while.zsh | |
parent | f538d7e75a4caba9d4bff0a3273c8cd5efa616ff (diff) |
home/zsh+pkgs: Add watch-while for long commands lol
Diffstat (limited to 'pkgs/watch-while/watch-while.zsh')
-rw-r--r-- | pkgs/watch-while/watch-while.zsh | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/pkgs/watch-while/watch-while.zsh b/pkgs/watch-while/watch-while.zsh new file mode 100644 index 0000000..d38d393 --- /dev/null +++ b/pkgs/watch-while/watch-while.zsh @@ -0,0 +1,19 @@ +#!@zsh@/bin/zsh + +set -ue + +# This file should be a (symbolik link to a) file which we want to watch. Once +# we're finished with that movie, we just read the next. +movie=${XDG_CONFIG_HOME:-$HOME/.config}/watch-while/movie + +if [ -f $movie ]; then + @mpv@/bin/mpv --save-position-on-quit --autofit='90%x90%' -- $movie >/dev/null 2>&1 & + mpv_pid=$? + trap 'kill -s QUIT $mpv_pid' EXIT + + # We don't exec because we want our exec handler to fire. + "$@" || exit $? +else + # In this case where we don't have any movie we just transparently run the command. + exec "$@" +fi |