From c5f50ca811c6077e9367c6d59b51ff73d910fd94 Mon Sep 17 00:00:00 2001 From: Phantop Date: Sun, 29 Jan 2023 16:30:32 -0500 Subject: [PATCH] aliases: move more intricate ones to functions --- bin/aliases | 62 ++------------------------------- fish/functions/alpine.fish | 7 ++++ fish/functions/ao3.fish | 6 ++++ fish/functions/listrecords.fish | 8 +++++ fish/functions/record.fish | 18 ++++++++++ fish/functions/viewrecord.fish | 16 +++++++++ 6 files changed, 57 insertions(+), 60 deletions(-) create mode 100644 fish/functions/alpine.fish create mode 100644 fish/functions/ao3.fish create mode 100644 fish/functions/listrecords.fish create mode 100644 fish/functions/record.fish create mode 100644 fish/functions/viewrecord.fish diff --git a/bin/aliases b/bin/aliases index b0b1e31..d51ff79 100755 --- a/bin/aliases +++ b/bin/aliases @@ -1,6 +1,6 @@ #!/usr/bin/fish rm -r ~/.config/fish/* -ln -s ../../.dotfiles/fish/config.fish ~/.config/fish +stow --no-folding -d ~/.dotfiles -t ~/.config/fish fish curl -sL https://git.io/fisher | source fisher install {jorgebucaran/replay,PatrickF1/fzf}.fish @@ -13,7 +13,6 @@ alias a 'alias -s' a acmus 'timeout (math 60 - (date +%M))m mpv --loop https://acmusicext.com/static/$argv/sunny/(date +%-I%P).ogg' a aliases 'v (env which aliases); command aliases' a all2jxl 'fd -e{png,jpg,ppm} -x cjxl -e 8 -d 0 {} {.}.jxl \; -x rm' -a ao3 'grep works/.\*/b $argv | cut -d/ -f3 | parallel curl -OJL ao3.org/downloads/{}/1.epub;:' a awall 'xwinwrap -fdt -fs -- mpv -wid WID ~/Pictures/Wall/Anim/$argv* --loop --no-osc' a base64d 'echo (echo $argv | base64 -d 2>/dev/null) | tee /dev/stderr 2>| clip;:' a catbox 'curl https://catbox.moe/user/api.php -F reqtype=fileupload -F fileToUpload=@$argv;:' @@ -79,64 +78,7 @@ for i in (cat ~/.config/qutebrowser/quickmarks | cut -d ' ' -f1) a $i "qutebrowser / \":open $i\"" end -for i in deemix diffoscope encodec git-sim lightnovel-crawler mandown mathicsscript nsz portablemc ratarmount scdl soundscrape spleeter +for i in deemix diffoscope encodec git-sim lightnovel-crawler mandown mathicsscript nsz pdf2docx portablemc ratarmount scdl soundscrape spleeter a $i "pipx run $i" end a mathics 'pipx run --spec mathics-django mathicsserver' - -function alpine - set url https://dl-cdn.alpinelinux.org/alpine/edge/releases/x86_64/ - set file (curl $url | grep s-2 | tac | sed -n 3p | cut -d\" -f2) - mkdir alpine; curl $url/$file | tar xf - -Calpine - cp /etc/resolv.conf alpine/etc - proot -r alpine -end -funcsave alpine - -function record - set recfile /tmp/fish_$fish_pid\_$(date +%s.%N) - set -g --append recfiles $recfile - set -g --append reclines "$argv" - set -g --append recfolds $PWD - - if test (type -t $argv[1]) = file - script -efq $recfile -c "$argv" - else - script -efq $recfile -c "fish -c '$argv'" - end - - zstdmt -c $recfile &| sponge $recfile - - function rmrec_(basename $recfile) --on-event fish_exit -V recfile - rm $recfile - end -end -funcsave record - -function listrecords - for i in (seq (count $recfiles)) - echo $i: $recfiles[$i] - printf \t; date -d @(echo $recfiles[$i] | cut -d_ -f3) - echo \t$reclines[$i] - echo \t$recfolds[$i] - end -end -funcsave listrecords - -function viewrecord - if test $argv - set num $argv - else - listrecords - echo Input the number of the desired recording: - set num (read) - end - - if test $KITTY_PID - kitty @ launch --type=tab --hold zstdcat $recfiles[$num] - else - clear - zstdcat $recfiles[$num] - end -end -funcsave viewrecord diff --git a/fish/functions/alpine.fish b/fish/functions/alpine.fish new file mode 100644 index 0000000..e1415b5 --- /dev/null +++ b/fish/functions/alpine.fish @@ -0,0 +1,7 @@ +function alpine + set url https://dl-cdn.alpinelinux.org/alpine/edge/releases/x86_64/ + set file (curl $url | grep s-2 | tac | sed -n 3p | cut -d\" -f2) + mkdir alpine; curl $url/$file | tar xf - -Calpine + cp /etc/resolv.conf alpine/etc + proot -r alpine -b /proc -b /dev +end diff --git a/fish/functions/ao3.fish b/fish/functions/ao3.fish new file mode 100644 index 0000000..9c6a2e2 --- /dev/null +++ b/fish/functions/ao3.fish @@ -0,0 +1,6 @@ +function ao3 + grep works/.\*/b $argv | cut -d/ -f3 | uniq | parallel curl -OJL ao3.org/downloads/{}/1.epub + for i in *.epub + mv $i (tar Oxf $i content.opf | pup | grep -A1 -m1 dc:title | tail -1 | sed 's/^ *//' | tr -d /).epub + end +end diff --git a/fish/functions/listrecords.fish b/fish/functions/listrecords.fish new file mode 100644 index 0000000..bf4e0ca --- /dev/null +++ b/fish/functions/listrecords.fish @@ -0,0 +1,8 @@ +function listrecords + for i in (seq (count $recfiles)) + echo $i: $recfiles[$i] + printf \t; date -d @(echo $recfiles[$i] | cut -d_ -f3) + echo \t$reclines[$i] + echo \t$recfolds[$i] + end +end diff --git a/fish/functions/record.fish b/fish/functions/record.fish new file mode 100644 index 0000000..b1f9c4f --- /dev/null +++ b/fish/functions/record.fish @@ -0,0 +1,18 @@ +function record + set recfile /tmp/fish_$fish_pid\_$(date +%s.%N) + set -g --append recfiles $recfile + set -g --append reclines "$argv" + set -g --append recfolds $PWD + + if test (type -t $argv[1]) = file + script -efq $recfile -c "$argv" + else + script -efq $recfile -c "fish -c '$argv'" + end + + zstdmt -c $recfile &| sponge $recfile + + function rmrec_(basename $recfile) --on-event fish_exit -V recfile + rm $recfile + end +end diff --git a/fish/functions/viewrecord.fish b/fish/functions/viewrecord.fish new file mode 100644 index 0000000..2c0185f --- /dev/null +++ b/fish/functions/viewrecord.fish @@ -0,0 +1,16 @@ +function viewrecord + if test $argv + set num $argv + else + listrecords + echo Input the number of the desired recording: + set num (read) + end + + if test $KITTY_PID + kitty @ launch --type=tab --hold zstdcat $recfiles[$num] + else + clear + zstdcat $recfiles[$num] + end +end