diff options
author | William Carroll <wpcarro@gmail.com> | 2018-01-08T20·42-0500 |
---|---|---|
committer | William Carroll <wpcarro@gmail.com> | 2018-01-08T20·42-0500 |
commit | 8cadd912a607efae3d2a92e9d49d03fe0eaf5a23 (patch) | |
tree | 028ecba141688c0daff6c9351854df39bac3becd | |
parent | 4f1d7650a455bce3424978d979647b0939a45372 (diff) |
Add misc bash helper functions
-rw-r--r-- | functions/misc_functions.sh | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/functions/misc_functions.sh b/functions/misc_functions.sh index 59bbdcf04992..cc4f39318d4f 100644 --- a/functions/misc_functions.sh +++ b/functions/misc_functions.sh @@ -4,6 +4,29 @@ function wgfb { } +# utility function for swapping filenames, eg init.el and init.el.bak +function swap-file-names { + file_a=$1 + file_b=$2 + backup=$(mktemp backup.XXX) + + mv ${file_a} ${backup} + mv ${file_b} ${file_a} + mv ${backup} ${file_b} + rm ${backup} + echo "Swapped: ${file_a} <-> ${file_b}" +} + + +# View a directory's contents in a periodically updated fashion. +function periodically-refresh-contents { + clear + lt . + sleep 1 + refresh-contents +} + + # download files to /tmp directory function wdownload { URL="$1" @@ -20,18 +43,6 @@ function wspcheck { } -# fuzzily search through dirs stack -function wfd { - dir=$(dirname $(fzf-tmux)) && pushd "$dir" >/dev/null -} - - -# pushd into a directory on your dirs stack -function wpushd { - dir="$(dirs | tr ' ' '\n' | fzf-tmux)" && pushd "$dir" -} - - # trims leading and trailing whitespace function trim { input="$1" @@ -131,3 +142,9 @@ function du-it-live () { echo -n '\b\b\b' && echo -n ' ' && echo -n '\r' done } + + +# programmatically get the router's IP address +function router { + netstat -nr | grep default | head -n 1 | awk '{ print $2 }' +} |