Add misc bash helper functions
This commit is contained in:
parent
4f1d7650a4
commit
8cadd912a6
1 changed files with 29 additions and 12 deletions
|
@ -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 }'
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue