diff options
author | Jesse Luehrs <doy@tozt.net> | 2017-01-16 06:56:53 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2017-01-21 06:37:31 -0500 |
commit | e8b5cc4e33cc2de38f290f747a00ecfdfafa140e (patch) | |
tree | c43da54470c717e0920a1b5882461e1bc8761bdf | |
parent | 941601ba04bc3abc64f7c0a385f0d78f89d3d1e4 (diff) | |
download | conf-e8b5cc4e33cc2de38f290f747a00ecfdfafa140e.tar.gz conf-e8b5cc4e33cc2de38f290f747a00ecfdfafa140e.zip |
split aliases and functions apart
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | aliases | 130 | ||||
-rw-r--r-- | bashrc | 1 | ||||
-rw-r--r-- | functions | 130 | ||||
-rw-r--r-- | zshrc | 1 |
5 files changed, 134 insertions, 129 deletions
@@ -6,6 +6,7 @@ INSTALL = agignore \ bashrc \ crawlrc \ env \ + functions \ gdbinit \ gitconfig \ gitignore \ @@ -39,135 +39,7 @@ alias wifi="sudo systemctl restart netctl-auto@wlp3s0" alias prove="forkprove" alias utc="TZ=UTC date" alias windows="VBoxManage startvm IE11\\ -\\ Win8.1" -function web { - local port=$1 - if [[ -z $port ]]; then - plackup -MPlack::App::Directory -e'Plack::App::Directory->new' - else - plackup -MPlack::App::Directory -e'Plack::App::Directory->new' --port $port - fi -} -function perldoc { - # XXX bash specific - if type cpandoc > /dev/null 2>&1; then - cpandoc "$@" - else - command perldoc "$@" - fi -} -alias pd=perldoc -function webcam { - local width=$1 - local height=$2 - if [[ -z $width ]]; then width=640; fi - if [[ -z $height ]]; then height=480; fi - mplayer tv:// -tv driver=v4l2:width=${width}:height=${height}:device=/dev/video0 -fps 15 -vf screenshot -} -function webcam_record { - local width=$1 - if [[ -z $width ]]; then width=640; else shift; fi - local height=$1 - if [[ -z $height ]]; then height=480; else shift; fi - mencoder tv:// -tv driver=v4l2:width=${width}:height=${height}:device=/dev/video0:forceaudio:adevice=/dev/dsp -ovc lavc -oac mp3lame -lameopts cbr:br=64:mode=3 -o $1 -} -function setfont { - printf '\e]710;%s\007\e]711;%s\007' "$1" "$1" -} -function mem_usage { - ps -eo rss,ucmd | sort -rn | head -n$([ -z "$1" ] && echo 20 || echo $1) -} -function opened_files { - strace $* 2>&1 | grep -E '^open\(' | \ - grep -v ENOENT | \ - grep -v O_DIRECTORY | \ - cut -f2 -d"\"" | \ - grep -vE '^/proc/' | \ - grep -v '^/sys/' | \ - grep -v '^/dev/' -} -function alert { - echo "DISPLAY=$DISPLAY xmessage -center -default okay $1" | at $2 -} -function fm22avi { - fceux --playmov $1.fm2 --sound 1 --soundq 1 --soundrate 48000 --nospritelim 1 --pal 0 --xscale 1 --yscale 1 --opengl 0 --special 0 $2 --videolog "mencoder - -o $1.avi -ovc x264 -x264encopts qp=0 -oac mp3lame -lameopts mode=3:preset=128 -noskip -nocache -mc 0 -aspect 4/3 NESVSETTINGS" -} -function pdfcat { - local out=$1 - shift - gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$out $* -} -function svup { - svc -u "$HOME/.services/$1" - svget "$1" -} -function svstop { - svc -d "$HOME/.services/$1" - svget "$1" -} -function svkill { - svc -k "$HOME/.services/$1" - svget "$1" -} -function svdn { - svst "$1" && svstop "$1" - svst "$1" && sleep 1 - svst "$1" && svstop "$1" - for i in 1..5; do - svst "$1" && sleep 1 - done - svst "$1" && svstop "$1" - for i in 1..10; do - svst "$1" && sleep 1 - done - svst "$1" && svkill "$1" -} -function svget { - svstat "$HOME/.services/$1" -} -function svst { - svget "$1" | grep -q ": up (" -} -function svre { - svdn "$1" - svup "$1" -} -function svlog { - tail -F "$HOME/.log/$1/current" | tai64nlocal -} -function pick_music { - lastfm_export --user doyster --dsn dbi:SQLite:${HOME}/.tracks.sqlite - sqlite3 ${HOME}/.tracks.sqlite "SELECT artist FROM yearly_tracks WHERE artist NOT IN (SELECT DISTINCT(artist) FROM weekly_tracks) GROUP BY artist ORDER BY count(artist) * (strftime('%s') - max(timestamp)) DESC LIMIT $([ -z "$1" ] && echo 20 || echo $1)" -} -function rand_music { - local db - if [[ $1 == '--old' ]]; then - db=old_tracks - shift - else - db=yearly_tracks - fi - lastfm_export --user doyster --dsn dbi:SQLite:${HOME}/.tracks.sqlite - for i in $(seq 1 $([ -z "$1" ] && echo 20 || echo $1)); do - echo "select distinct(artist) from $db where artist not in (select distinct(artist) from weekly_tracks);" | sqlite3 ~/.tracks.sqlite | rand_line | sed "s/'/''/" | sed "s/.*/select artist, album from $db where artist = '&' group by artist, album;/" | sqlite3 ~/.tracks.sqlite | rand_line | sed 's/|/ - /' - done -} -function t { - if [[ -d blib ]]; then - perl -Mblib -MTest::Pretty "$@" - else - perl -Ilib -MTest::Pretty "$@" - fi -} -function pt { - if [[ -d blib ]]; then - prove -Mlib::require::all=blib/lib,blib/arch -Pretty -b "$@" t - else - prove -Mlib::require::all=lib -Pretty -l "$@" t - fi -} -function hostcert { - openssl s_client -connect "$1" < /dev/null 2>/dev/null | perl -nle 'print if /BEGIN CERTIFICATE/../END CERTIFICATE/' | openssl x509 -text | perl -nle 'print unless /BEGIN CERTIFICATE/../END CERTIFICATE/' -} +alias pd="perldoc" # }}} # vim:ft=sh: @@ -22,6 +22,7 @@ case ${TERM} in esac # }}} # aliases {{{ [ -f "$HOME/.aliases" ] && source $HOME/.aliases +[ -f "$HOME/.functions" ] && source $HOME/.functions # }}} # completion {{{ [ -f /etc/bash_completion ] && source /etc/bash_completion diff --git a/functions b/functions new file mode 100644 index 0000000..78e07fd --- /dev/null +++ b/functions @@ -0,0 +1,130 @@ +function web { + local port=$1 + if [[ -z $port ]]; then + plackup -MPlack::App::Directory -e'Plack::App::Directory->new' + else + plackup -MPlack::App::Directory -e'Plack::App::Directory->new' --port $port + fi +} +function perldoc { + # XXX bash specific + if type cpandoc > /dev/null 2>&1; then + cpandoc "$@" + else + command perldoc "$@" + fi +} +function webcam { + local width=$1 + local height=$2 + if [[ -z $width ]]; then width=640; fi + if [[ -z $height ]]; then height=480; fi + mplayer tv:// -tv driver=v4l2:width=${width}:height=${height}:device=/dev/video0 -fps 15 -vf screenshot +} +function webcam_record { + local width=$1 + if [[ -z $width ]]; then width=640; else shift; fi + local height=$1 + if [[ -z $height ]]; then height=480; else shift; fi + mencoder tv:// -tv driver=v4l2:width=${width}:height=${height}:device=/dev/video0:forceaudio:adevice=/dev/dsp -ovc lavc -oac mp3lame -lameopts cbr:br=64:mode=3 -o $1 +} +function setfont { + printf '\e]710;%s\007\e]711;%s\007' "$1" "$1" +} +function mem_usage { + ps -eo rss,ucmd | sort -rn | head -n$([ -z "$1" ] && echo 20 || echo $1) +} +function opened_files { + strace $* 2>&1 | grep -E '^open\(' | \ + grep -v ENOENT | \ + grep -v O_DIRECTORY | \ + cut -f2 -d"\"" | \ + grep -vE '^/proc/' | \ + grep -v '^/sys/' | \ + grep -v '^/dev/' +} +function alert { + echo "DISPLAY=$DISPLAY xmessage -center -default okay $1" | at $2 +} +function fm22avi { + fceux --playmov $1.fm2 --sound 1 --soundq 1 --soundrate 48000 --nospritelim 1 --pal 0 --xscale 1 --yscale 1 --opengl 0 --special 0 $2 --videolog "mencoder - -o $1.avi -ovc x264 -x264encopts qp=0 -oac mp3lame -lameopts mode=3:preset=128 -noskip -nocache -mc 0 -aspect 4/3 NESVSETTINGS" +} +function pdfcat { + local out=$1 + shift + gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$out $* +} +function svup { + svc -u "$HOME/.services/$1" + svget "$1" +} +function svstop { + svc -d "$HOME/.services/$1" + svget "$1" +} +function svkill { + svc -k "$HOME/.services/$1" + svget "$1" +} +function svdn { + svst "$1" && svstop "$1" + svst "$1" && sleep 1 + svst "$1" && svstop "$1" + for i in 1..5; do + svst "$1" && sleep 1 + done + svst "$1" && svstop "$1" + for i in 1..10; do + svst "$1" && sleep 1 + done + svst "$1" && svkill "$1" +} +function svget { + svstat "$HOME/.services/$1" +} +function svst { + svget "$1" | grep -q ": up (" +} +function svre { + svdn "$1" + svup "$1" +} +function svlog { + tail -F "$HOME/.log/$1/current" | tai64nlocal +} +function pick_music { + lastfm_export --user doyster --dsn dbi:SQLite:${HOME}/.tracks.sqlite + sqlite3 ${HOME}/.tracks.sqlite "SELECT artist FROM yearly_tracks WHERE artist NOT IN (SELECT DISTINCT(artist) FROM weekly_tracks) GROUP BY artist ORDER BY count(artist) * (strftime('%s') - max(timestamp)) DESC LIMIT $([ -z "$1" ] && echo 20 || echo $1)" +} +function rand_music { + local db + if [[ $1 == '--old' ]]; then + db=old_tracks + shift + else + db=yearly_tracks + fi + lastfm_export --user doyster --dsn dbi:SQLite:${HOME}/.tracks.sqlite + for i in $(seq 1 $([ -z "$1" ] && echo 20 || echo $1)); do + echo "select distinct(artist) from $db where artist not in (select distinct(artist) from weekly_tracks);" | sqlite3 ~/.tracks.sqlite | rand_line | sed "s/'/''/" | sed "s/.*/select artist, album from $db where artist = '&' group by artist, album;/" | sqlite3 ~/.tracks.sqlite | rand_line | sed 's/|/ - /' + done +} +function t { + if [[ -d blib ]]; then + perl -Mblib -MTest::Pretty "$@" + else + perl -Ilib -MTest::Pretty "$@" + fi +} +function pt { + if [[ -d blib ]]; then + prove -Mlib::require::all=blib/lib,blib/arch -Pretty -b "$@" t + else + prove -Mlib::require::all=lib -Pretty -l "$@" t + fi +} +function hostcert { + openssl s_client -connect "$1" < /dev/null 2>/dev/null | perl -nle 'print if /BEGIN CERTIFICATE/../END CERTIFICATE/' | openssl x509 -text | perl -nle 'print unless /BEGIN CERTIFICATE/../END CERTIFICATE/' +} + +# vim:ft=sh: @@ -19,6 +19,7 @@ case ${TERM} in esac # }}} # aliases {{{ [ -f "$HOME/.aliases" ] && source $HOME/.aliases +[ -f "$HOME/.functions" ] && source $HOME/.functions mkdir -p $HOME/.vim/data/hist function vim { local zsh_hist_fname |