fish: use startup files for command scripts

master
an 2019-07-27 08:30:14 -04:00
parent 5930fc191a
commit 2ba04a89e7
29 changed files with 143 additions and 120 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
scripts/fish/priv

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,6 +0,0 @@
#!/usr/bin/env fish
# vim: syntax=fish:
while true
x11vnc -forever -scale 0.25
end

View File

@ -1 +0,0 @@
priv

11
scripts/fish/build-hosts Executable file
View File

@ -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

View File

@ -1,3 +1,5 @@
# vim: syntax=fish:
function cheat.sh -d 'Grabs a sheet from cheat.sh' -a arg
curl cheat.sh/$arg
end

16
scripts/fish/crtolf Executable file
View File

@ -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

View File

@ -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

19
scripts/fish/find-stereo Executable file
View File

@ -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

18
scripts/fish/flac2mp3 Executable file
View File

@ -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

8
scripts/fish/generate-grub Executable file
View File

@ -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

View File

@ -1,3 +1,5 @@
# vim: syntax=fish:
set -x HOMEBREW_NO_ANALYTICS 1
set -x HOMEBREW_INSTALL_BADGE 'OK'

7
scripts/fish/makepkg Normal file
View File

@ -0,0 +1,7 @@
# vim: syntax=fish:
function emit-srcinfo -d 'Emits .SRCINFO'
makepkg --printsrcinfo > .SRCINFO
end
## EOF

View File

@ -1,5 +0,0 @@
function emit-srcinfo
makepkg --printsrcinfo > .SRCINFO
end
## EOF

7
scripts/fish/megadl Executable file
View File

@ -0,0 +1,7 @@
# vim: syntax=fish:
function megadl-all -d 'Downloads all files in ~/dl'
megadl (cat ~/dl)
end
## EOF

View File

@ -1,5 +0,0 @@
function megadl-all
megadl (cat ~/dl)
end
## EOF

View File

@ -1,3 +1,5 @@
# vim: syntax=fish:
function fish_prompt
echo (set_color c792ea)"$hostname% "(set_color normal)
end

View File

@ -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)

7
scripts/fish/rebuild Normal file
View File

@ -0,0 +1,7 @@
# vim: syntax=fish:
function rebuild -d 'Builds an AUR package'
$HOME/src/scripts/rebuild.rkt $argv
end
## EOF

View File

@ -1,5 +0,0 @@
function rebuild
$HOME/src/scripts/rebuild.rkt $argv
end
## EOF

View File

@ -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

View File

@ -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

9
scripts/fish/vnc Executable file
View File

@ -0,0 +1,9 @@
# vim: syntax=fish:
function vnc -d 'Runs x11vnc, always'
while true
x11vnc -forever -scale 0.25
end
end
## EOF