From aaf67bea461d3bf663fba8a915bb06fb30eb7c4a Mon Sep 17 00:00:00 2001 From: mitchell Date: Wed, 9 Mar 2022 16:29:18 -0500 Subject: [PATCH] Add alias and refactor scripts/ --- .config/fish/functions/define_aliases.fish | 1 + .config/fish/functions/glance.fish | 7 +++ .config/fish/functions/jmpv.fish | 4 ++ .config/fish/functions/ytmpv.fish | 50 ++++++++++++++++++---- scripts/glance | 2 +- scripts/jmpv | 2 +- 6 files changed, 55 insertions(+), 11 deletions(-) create mode 100644 .config/fish/functions/glance.fish create mode 100644 .config/fish/functions/jmpv.fish diff --git a/.config/fish/functions/define_aliases.fish b/.config/fish/functions/define_aliases.fish index 6547a05..e8a939f 100644 --- a/.config/fish/functions/define_aliases.fish +++ b/.config/fish/functions/define_aliases.fish @@ -1,4 +1,5 @@ function define_aliases -a uname -d 'Defines aliases for commonly used commands' + alias q 'exit' alias rcp 'rsync -aP' alias vg 'vagrant' alias tf 'terraform' diff --git a/.config/fish/functions/glance.fish b/.config/fish/functions/glance.fish new file mode 100644 index 0000000..0008c40 --- /dev/null +++ b/.config/fish/functions/glance.fish @@ -0,0 +1,7 @@ +function glance -d 'Open glances on a preset of machines' + tmux new -s glance mosh arch@khetanna.lan -- glances --disable-process --sparkline\; \ + neww mosh arch@kamino.lan -- glances --disable-process --sparkline\; \ + neww mosh arch@marauder.lan -- glances --disable-process --sparkline\; \ + neww mosh serenity.lan -- glances --disable-process --sparkline + or tmux attach-session -t glance +end diff --git a/.config/fish/functions/jmpv.fish b/.config/fish/functions/jmpv.fish new file mode 100644 index 0000000..6598696 --- /dev/null +++ b/.config/fish/functions/jmpv.fish @@ -0,0 +1,4 @@ +function jmpv -d 'Open jellyfin-mpv-shim in a tmux session of its own' + tmux new-session -s jmpv jellyfin-mpv-shim + or tmux attach-session -t jmpv +end diff --git a/.config/fish/functions/ytmpv.fish b/.config/fish/functions/ytmpv.fish index 2413481..98f69c1 100644 --- a/.config/fish/functions/ytmpv.fish +++ b/.config/fish/functions/ytmpv.fish @@ -1,6 +1,13 @@ function ytmpv -d 'A script to help queue youtube videos on MPV' - if not set -Uq _ytmpv_video_queue - set -U _ytmpv_video_queue + set -l queue ~/.ytmpv_queue + set -l downloads ~/.ytmpv_downloads/ + + if not test -f $queue + touch $queue + end + + if not test -d $downloads + mkdir $downloads end while read -P 'url(s)/command (play)> ' -l video @@ -9,26 +16,51 @@ function ytmpv -d 'A script to help queue youtube videos on MPV' clear case c copy set -l video (fromcb) - set -U _ytmpv_video_queue $_ytmpv_video_queue (string split ' ' $video) + string split ' ' $video >> $queue case d destroy - set -Ue _ytmpv_video_queue + rm -r $queue $downloads + break + case dl download + set -l urls (cat $queue) + read -P 'username> ' -l username + read -P 'password> ' -s -l password + + tmux attach -t ytdlp + tmux new-session -s ytdlp -- \ + yt-dlp \ + --username="$username" \ + --password="$password" \ + --paths=$downloads \ + --write-subs \ + $urls + + break case f fg tmux attach -t ytmpv case h help functions ytmpv case l list - string split ' ' $_ytmpv_video_queue + cat $queue case p play + tmux attach -t ytmpv + tmux new-session -s ytmpv -- mpv --save-position-on-quit --playlist=$queue + break + case pdl play-downloads + tmux attach -t ytmpv + tmux new-session -s ytmpv -- mpv --save-position-on-quit $downloads break case q quit return case '*' - test -z "$video"; and break - set -U _ytmpv_video_queue $_ytmpv_video_queue (string split ' ' $video) + if test -z "$video" + tmux attach -t ytmpv + tmux new-session -s ytmpv -- mpv --save-position-on-quit --playlist=$queue + break + end + + string split ' ' $video >> $queue end end - tmux attach -t ytmpv - tmux new-session -s ytmpv -- mpv --save-position-on-quit $_ytmpv_video_queue ytmpv end diff --git a/scripts/glance b/scripts/glance index d740e1d..48fb2d5 100755 --- a/scripts/glance +++ b/scripts/glance @@ -1,2 +1,2 @@ #!/bin/sh -kitty tmux new -s glance mosh arch@khetanna.lan -- glances --sparkline\; neww mosh serenity.lan -- glances --sparkline +kitty fish -C glance diff --git a/scripts/jmpv b/scripts/jmpv index ce521a8..34bc659 100755 --- a/scripts/jmpv +++ b/scripts/jmpv @@ -1,2 +1,2 @@ #!/usr/bin/sh -kitty tmux new-session -s jmpv jellyfin-mpv-shim +kitty fish -c jmpv