From 2ba04a89e7c9930055d6d0c30285c3d2853cd261 Mon Sep 17 00:00:00 2001 From: Alison Watson Date: Sat, 27 Jul 2019 08:30:14 -0400 Subject: [PATCH] fish: use startup files for command scripts --- .gitignore | 1 + applications/fish | 2 +- scripts/cmds/build-hosts | 10 ---------- scripts/cmds/crtolf | 15 --------------- scripts/cmds/find-no-album-artist | 17 ----------------- scripts/cmds/find-stereo | 18 ------------------ scripts/cmds/flac2mp3 | 18 ------------------ scripts/cmds/generate-grub | 7 ------- scripts/cmds/vnc | 6 ------ scripts/fish/.gitignore | 1 - scripts/fish/build-hosts | 11 +++++++++++ scripts/fish/{cheat.fish => cheat} | 2 ++ scripts/fish/crtolf | 16 ++++++++++++++++ scripts/fish/find-no-album-artist | 18 ++++++++++++++++++ scripts/fish/find-stereo | 19 +++++++++++++++++++ scripts/fish/flac2mp3 | 18 ++++++++++++++++++ scripts/fish/generate-grub | 8 ++++++++ scripts/fish/{homebrew.fish => homebrew} | 2 ++ scripts/fish/makepkg | 7 +++++++ scripts/fish/makepkg.fish | 5 ----- scripts/fish/megadl | 7 +++++++ scripts/fish/megadl.fish | 5 ----- scripts/fish/{prompt.fish => prompt} | 2 ++ scripts/fish/{ql.fish => ql} | 2 ++ scripts/fish/rebuild | 7 +++++++ scripts/fish/rebuild.fish | 5 ----- scripts/fish/{transfer.fish => transfer} | 2 ++ scripts/{cmds => fish}/update-vim-plugins | 23 +++++++++++------------ scripts/fish/vnc | 9 +++++++++ 29 files changed, 143 insertions(+), 120 deletions(-) create mode 100644 .gitignore delete mode 100755 scripts/cmds/build-hosts delete mode 100755 scripts/cmds/crtolf delete mode 100755 scripts/cmds/find-no-album-artist delete mode 100755 scripts/cmds/find-stereo delete mode 100755 scripts/cmds/flac2mp3 delete mode 100755 scripts/cmds/generate-grub delete mode 100755 scripts/cmds/vnc delete mode 100644 scripts/fish/.gitignore create mode 100755 scripts/fish/build-hosts rename scripts/fish/{cheat.fish => cheat} (87%) create mode 100755 scripts/fish/crtolf create mode 100755 scripts/fish/find-no-album-artist create mode 100755 scripts/fish/find-stereo create mode 100755 scripts/fish/flac2mp3 create mode 100755 scripts/fish/generate-grub rename scripts/fish/{homebrew.fish => homebrew} (77%) create mode 100644 scripts/fish/makepkg delete mode 100644 scripts/fish/makepkg.fish create mode 100755 scripts/fish/megadl delete mode 100755 scripts/fish/megadl.fish rename scripts/fish/{prompt.fish => prompt} (94%) rename scripts/fish/{ql.fish => ql} (97%) create mode 100644 scripts/fish/rebuild delete mode 100644 scripts/fish/rebuild.fish rename scripts/fish/{transfer.fish => transfer} (85%) rename scripts/{cmds => fish}/update-vim-plugins (56%) create mode 100755 scripts/fish/vnc diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b76e1ce --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +scripts/fish/priv diff --git a/applications/fish b/applications/fish index 6ebb548..bbca361 100644 --- a/applications/fish +++ b/applications/fish @@ -34,7 +34,7 @@ if test -f ~/.cargo/env source ~/.cargo/env end -for f in (find $_agw_dir_scripts/fish -type f -name '*.fish') +for f in (find $_agw_dir_scripts/fish -type f) source $f end diff --git a/scripts/cmds/build-hosts b/scripts/cmds/build-hosts deleted file mode 100755 index 615bd32..0000000 --- a/scripts/cmds/build-hosts +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env fish -# vim: syntax=fish: - -cd $_agw_dir_src/hosts -git pull - -sudo sh -c "cat $_agw_dir_rc/applications/hosts > /etc/hosts" -sudo sh -c "cat $_agw_dir_src/hosts/hosts >> /etc/hosts" - -## EOF diff --git a/scripts/cmds/crtolf b/scripts/cmds/crtolf deleted file mode 100755 index faa337d..0000000 --- a/scripts/cmds/crtolf +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env fish -# vim: syntax=fish: - -for f in (find . -type f) - set ftype (file -b --mime-type "$f") - set basetype (string split "/" "$ftype") - - if test "$basetype[1]" = "text" - set tmp (mktemp) - mac2unix -n "$f" "$tmp" - mv "$tmp" "$f" - end -end - -## EOF diff --git a/scripts/cmds/find-no-album-artist b/scripts/cmds/find-no-album-artist deleted file mode 100755 index 6496ce3..0000000 --- a/scripts/cmds/find-no-album-artist +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env fish -# vim: syntax=fish: - -set filter 'pan=mono|c0=0.5*FL+-0.5*FR,silenceremove=start_periods=1:detection=peak' - -for f in (find . -type f \( -name "*.ogg" -o \ - -name "*.flac" -o \ - -name "*.mp3" -o \ - -name "*.opus" \)) - set out (ffprobe "$f" 2>/dev/null | rg "album_artist") - - if test ! "$out" - echo "$f has no album artist tag" - end -end - -## EOF diff --git a/scripts/cmds/find-stereo b/scripts/cmds/find-stereo deleted file mode 100755 index 104e684..0000000 --- a/scripts/cmds/find-stereo +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env fish -# vim: syntax=fish: - -set filter 'pan=mono|c0=0.5*FL+-0.5*FR,silenceremove=start_periods=1:detection=peak' - -for f in $argv - set out (ffmpeg -nostdin -loglevel error -i "$f" -filter_complex "$filter" -t 0.00002 -f crc -) - - if test "$out" != 'CRC=0x00000001' - set other /tmp/(basename "$f") - echo "$f is stereo, converting" - ffmpeg -i "$f" -ac 1 "$other" && mv "$other" "$f" - else - echo "$f is mono" - end -end - -## EOF diff --git a/scripts/cmds/flac2mp3 b/scripts/cmds/flac2mp3 deleted file mode 100755 index 3c2bf25..0000000 --- a/scripts/cmds/flac2mp3 +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env fish -# vim: syntax=fish: - -function fail - echo "failed to process $f, exiting" - exit 1 -end - -for f in ./*.flac - ffmpeg -i "$f" -q:a 0 -vn (basename "$f" ".flac")".mp3" - or fail - echo "$f success" -end - -read -P "success. delete files? [yn] " yn - -test $yn = y -and rm ./*.flac diff --git a/scripts/cmds/generate-grub b/scripts/cmds/generate-grub deleted file mode 100755 index 5d5182f..0000000 --- a/scripts/cmds/generate-grub +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env sh -# vim: syntax=sh: - -grub-mkconfig -o /boot/grub/grub.cfg -grub-install --target=x86_64-efi --efi-directory=/efi --bootloader-id=arch - -## EOF diff --git a/scripts/cmds/vnc b/scripts/cmds/vnc deleted file mode 100755 index cf611bb..0000000 --- a/scripts/cmds/vnc +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env fish -# vim: syntax=fish: - -while true - x11vnc -forever -scale 0.25 -end diff --git a/scripts/fish/.gitignore b/scripts/fish/.gitignore deleted file mode 100644 index 8d1ef24..0000000 --- a/scripts/fish/.gitignore +++ /dev/null @@ -1 +0,0 @@ -priv diff --git a/scripts/fish/build-hosts b/scripts/fish/build-hosts new file mode 100755 index 0000000..721d7de --- /dev/null +++ b/scripts/fish/build-hosts @@ -0,0 +1,11 @@ +# vim: syntax=fish: + +function build-hosts -d 'Builds /etc/hosts' + cd $_agw_dir_src/hosts + git pull + + sudo sh -c "cat $_agw_dir_rc/applications/hosts > /etc/hosts" + sudo sh -c "cat $_agw_dir_src/hosts/hosts >> /etc/hosts" +end + +## EOF diff --git a/scripts/fish/cheat.fish b/scripts/fish/cheat similarity index 87% rename from scripts/fish/cheat.fish rename to scripts/fish/cheat index afe3bec..5a41be9 100644 --- a/scripts/fish/cheat.fish +++ b/scripts/fish/cheat @@ -1,3 +1,5 @@ +# vim: syntax=fish: + function cheat.sh -d 'Grabs a sheet from cheat.sh' -a arg curl cheat.sh/$arg end diff --git a/scripts/fish/crtolf b/scripts/fish/crtolf new file mode 100755 index 0000000..68d3ec2 --- /dev/null +++ b/scripts/fish/crtolf @@ -0,0 +1,16 @@ +# vim: syntax=fish: + +function crtolf -d 'Converts all CR=EOL files to LF=EOL' + for f in (find . -type f) + set ftype (file -b --mime-type "$f") + set basetype (string split "/" "$ftype") + + if test "$basetype[1]" = "text" + set tmp (mktemp) + mac2unix -n "$f" "$tmp" + mv "$tmp" "$f" + end + end +end + +## EOF diff --git a/scripts/fish/find-no-album-artist b/scripts/fish/find-no-album-artist new file mode 100755 index 0000000..d06e01c --- /dev/null +++ b/scripts/fish/find-no-album-artist @@ -0,0 +1,18 @@ +# vim: syntax=fish: + +function find-no-album-artist -d "Finds files which don't have an album artist" + set filter 'pan=mono|c0=0.5*FL+-0.5*FR,silenceremove=start_periods=1:detection=peak' + + for f in (find . -type f \( -name "*.ogg" -o \ + -name "*.flac" -o \ + -name "*.mp3" -o \ + -name "*.opus" \)) + set out (ffprobe "$f" 2>/dev/null | rg "album_artist") + + if test ! "$out" + echo "$f has no album artist tag" + end + end +end + +## EOF diff --git a/scripts/fish/find-stereo b/scripts/fish/find-stereo new file mode 100755 index 0000000..b349c16 --- /dev/null +++ b/scripts/fish/find-stereo @@ -0,0 +1,19 @@ +# vim: syntax=fish: + +function find-stereo -d 'Finds files that are stereo' + set filter 'pan=mono|c0=0.5*FL+-0.5*FR,silenceremove=start_periods=1:detection=peak' + + for f in $argv + set out (ffmpeg -nostdin -loglevel error -i "$f" -filter_complex "$filter" -t 0.00002 -f crc -) + + if test "$out" != 'CRC=0x00000001' + set other /tmp/(basename "$f") + echo "$f is stereo, converting" + ffmpeg -i "$f" -ac 1 "$other" && mv "$other" "$f" + else + echo "$f is mono" + end + end +end + +## EOF diff --git a/scripts/fish/flac2mp3 b/scripts/fish/flac2mp3 new file mode 100755 index 0000000..fac6038 --- /dev/null +++ b/scripts/fish/flac2mp3 @@ -0,0 +1,18 @@ +# vim: syntax=fish: + +function flac2mp3 -d 'Converts FLAC files to MP3' + for f in ./*.flac + if not ffmpeg -i "$f" -q:a 0 -vn (basename "$f" ".flac")".mp3" + echo "failed to process $f, exiting" + exit 1 + end + echo "$f success" + end + + read -P "success. delete files? [yn] " yn + + test $yn = y + and rm ./*.flac +end + +## EOF diff --git a/scripts/fish/generate-grub b/scripts/fish/generate-grub new file mode 100755 index 0000000..28212bf --- /dev/null +++ b/scripts/fish/generate-grub @@ -0,0 +1,8 @@ +# vim: syntax=fish: + +function generate-grub -d 'Generates and installs GRUB' + sudo grub-mkconfig -o /boot/grub/grub.cfg + sudo grub-install --target=x86_64-efi --efi-directory=/efi --bootloader-id=arch +end + +## EOF diff --git a/scripts/fish/homebrew.fish b/scripts/fish/homebrew similarity index 77% rename from scripts/fish/homebrew.fish rename to scripts/fish/homebrew index c6a244c..bf9fb6b 100644 --- a/scripts/fish/homebrew.fish +++ b/scripts/fish/homebrew @@ -1,3 +1,5 @@ +# vim: syntax=fish: + set -x HOMEBREW_NO_ANALYTICS 1 set -x HOMEBREW_INSTALL_BADGE 'OK' diff --git a/scripts/fish/makepkg b/scripts/fish/makepkg new file mode 100644 index 0000000..79f91b6 --- /dev/null +++ b/scripts/fish/makepkg @@ -0,0 +1,7 @@ +# vim: syntax=fish: + +function emit-srcinfo -d 'Emits .SRCINFO' + makepkg --printsrcinfo > .SRCINFO +end + +## EOF diff --git a/scripts/fish/makepkg.fish b/scripts/fish/makepkg.fish deleted file mode 100644 index 4e9d14a..0000000 --- a/scripts/fish/makepkg.fish +++ /dev/null @@ -1,5 +0,0 @@ -function emit-srcinfo - makepkg --printsrcinfo > .SRCINFO -end - -## EOF diff --git a/scripts/fish/megadl b/scripts/fish/megadl new file mode 100755 index 0000000..0361f74 --- /dev/null +++ b/scripts/fish/megadl @@ -0,0 +1,7 @@ +# vim: syntax=fish: + +function megadl-all -d 'Downloads all files in ~/dl' + megadl (cat ~/dl) +end + +## EOF diff --git a/scripts/fish/megadl.fish b/scripts/fish/megadl.fish deleted file mode 100755 index ce2c49c..0000000 --- a/scripts/fish/megadl.fish +++ /dev/null @@ -1,5 +0,0 @@ -function megadl-all - megadl (cat ~/dl) -end - -## EOF diff --git a/scripts/fish/prompt.fish b/scripts/fish/prompt similarity index 94% rename from scripts/fish/prompt.fish rename to scripts/fish/prompt index b51703c..e5423ed 100644 --- a/scripts/fish/prompt.fish +++ b/scripts/fish/prompt @@ -1,3 +1,5 @@ +# vim: syntax=fish: + function fish_prompt echo (set_color c792ea)"$hostname% "(set_color normal) end diff --git a/scripts/fish/ql.fish b/scripts/fish/ql similarity index 97% rename from scripts/fish/ql.fish rename to scripts/fish/ql index 60b2679..cab0d2f 100644 --- a/scripts/fish/ql.fish +++ b/scripts/fish/ql @@ -1,3 +1,5 @@ +# vim: syntax=fish: + function ql -d 'Changes directory to a quicklink' -a name if not set -q quicklink_$name name echo (set_color red)"error: no quicklink named $name"(set_color normal) diff --git a/scripts/fish/rebuild b/scripts/fish/rebuild new file mode 100644 index 0000000..d940099 --- /dev/null +++ b/scripts/fish/rebuild @@ -0,0 +1,7 @@ +# vim: syntax=fish: + +function rebuild -d 'Builds an AUR package' + $HOME/src/scripts/rebuild.rkt $argv +end + +## EOF diff --git a/scripts/fish/rebuild.fish b/scripts/fish/rebuild.fish deleted file mode 100644 index eb1fdfb..0000000 --- a/scripts/fish/rebuild.fish +++ /dev/null @@ -1,5 +0,0 @@ -function rebuild - $HOME/src/scripts/rebuild.rkt $argv -end - -## EOF diff --git a/scripts/fish/transfer.fish b/scripts/fish/transfer similarity index 85% rename from scripts/fish/transfer.fish rename to scripts/fish/transfer index 1ad3145..8da4020 100644 --- a/scripts/fish/transfer.fish +++ b/scripts/fish/transfer @@ -1,3 +1,5 @@ +# vim: syntax=fish: + function vis-transfer -d 'Shows how a transfer is doing with pv' -a name tail -f "$name" | pv > /dev/null end diff --git a/scripts/cmds/update-vim-plugins b/scripts/fish/update-vim-plugins similarity index 56% rename from scripts/cmds/update-vim-plugins rename to scripts/fish/update-vim-plugins index 4632bcd..24efe98 100755 --- a/scripts/cmds/update-vim-plugins +++ b/scripts/fish/update-vim-plugins @@ -1,7 +1,8 @@ -#!/usr/bin/env fish # vim: syntax=fish: -function pull_plugins +function pull-vim-plugin -d 'Updates all vim plugins in the current directory' + cd $argv[1] + for plugin in ./* cd $plugin @@ -24,23 +25,21 @@ function pull_plugins cd .. end -end -function cd_and_pull - cd $argv[1] - pull_plugins cd .. end -cd ~/.vim/pack +function update-vim-plugins -d 'Updates all vim plugins' + cd ~/.vim/pack -for folder in ./* - cd $folder + for folder in ./* + cd $folder - test -d start; and cd_and_pull start - test -d opt; and cd_and_pull opt + test -d start; and pull-vim-plugin start + test -d opt; and pull-vim-plugin opt - cd .. + cd .. + end end ## EOF diff --git a/scripts/fish/vnc b/scripts/fish/vnc new file mode 100755 index 0000000..1e80310 --- /dev/null +++ b/scripts/fish/vnc @@ -0,0 +1,9 @@ +# vim: syntax=fish: + +function vnc -d 'Runs x11vnc, always' + while true + x11vnc -forever -scale 0.25 + end +end + +## EOF