From 2ece2a2987dcbb28283f2337c466f755cdb9c007 Mon Sep 17 00:00:00 2001 From: katherine Date: Tue, 2 Feb 2016 05:55:28 -0700 Subject: local function variables i feel dumb --- .zshrc-freebsd | 6 +++--- .zshrc-linux | 6 +++--- .zshrc-linux-desktop | 15 ++++++++++++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.zshrc-freebsd b/.zshrc-freebsd index 0525972..04cc950 100644 --- a/.zshrc-freebsd +++ b/.zshrc-freebsd @@ -16,9 +16,9 @@ export PAGER="less -R" # bits to human readable value b2h() { - suffixes=( 'B' 'K' 'M' 'G' 'T' 'P' 'E' 'Z' 'Y' ) - sindex=1 - val=$1 + local suffixes=( 'B' 'K' 'M' 'G' 'T' 'P' 'E' 'Z' 'Y' ) + local sindex=1 + local val=$1 [[ -z $(echo $1 | grep "^[0-9]*$") ]] && read val while [[ $(echo $val / 1024 | bc) -ne 0 ]]; do diff --git a/.zshrc-linux b/.zshrc-linux index 46d325f..03ab373 100644 --- a/.zshrc-linux +++ b/.zshrc-linux @@ -23,9 +23,9 @@ export PAGER="less -R" # bits to human readable value b2h() { - suffixes=( 'B' 'K' 'M' 'G' 'T' 'P' 'E' 'Z' 'Y' ) - sindex=1 - val=$1 + local suffixes=( 'B' 'K' 'M' 'G' 'T' 'P' 'E' 'Z' 'Y' ) + local sindex=1 + local val=$1 [[ -z $(echo $1 | grep "^[0-9]*$") ]] && read val while [[ $(echo $val / 1024 | bc) -ne 0 ]]; do diff --git a/.zshrc-linux-desktop b/.zshrc-linux-desktop index f52a02d..b85fab0 100644 --- a/.zshrc-linux-desktop +++ b/.zshrc-linux-desktop @@ -19,6 +19,7 @@ mpd-sleep() { # leaks memory for some reason, so don't run on a clean library # or it'll crash everything mpd-cover-convert() { + local d find ~/music -type f -regextype posix-extended -regex ".*cover\.(png|jpg)"\ | while read file; do d=$(dirname "$file") @@ -142,6 +143,8 @@ scap() { # quickly send a file to hosted tmp dir send() { + local name + local basename if [[ "$1" ]]; then scp $@ shmibbles.me:http/tmp/ if [[ $? -eq 0 ]]; then @@ -164,6 +167,7 @@ send() { ssh-scrot() { archey3 + local name if [[ "$1" != "" ]]; then name=$1 else @@ -171,9 +175,9 @@ ssh-scrot() { read name fi - date=$(date +'%Y-%m-%d') + local date=$(date +'%Y-%m-%d') - folder="http/img/scrot" + local folder="http/img/scrot" ssh shmibbles.me "mkdir -p $folder/$date" if [[ "${?#0}" != "" ]]; then @@ -221,12 +225,14 @@ make-gif() { ln -s "$1" make-gif-in + local start echo -n "start [00:00:00]: " read start if [[ -z "$start" ]]; then start="00:00:00" fi + local length echo -n "length [full]: " read length if [[ -z "$length" ]]; then @@ -236,18 +242,21 @@ make-gif() { t="-t" fi + local fps echo -n "fps [10]: " read fps if [[ -z "$fps" ]]; then fps="10" fi + local width echo -n "width [480]: " read width if [[ -z "$width" ]]; then width="480" fi + local subs echo -n "use subtitles? [y/N]: " read subs if [[ "$subs" == "y" || "$subs" == "Y" ]]; then @@ -277,7 +286,7 @@ make-gif() { # um... fuck() { - fuck="fuck" + local fuck="fuck" while true; do echo -en "\e[$((RANDOM%2));$((RANDOM%8+30))m" -- cgit v1.2.3