Skip to content

Instantly share code, notes, and snippets.

@wrightrocket
Created March 16, 2018 20:25
Show Gist options
  • Save wrightrocket/3d824b49c0dc18832080aeb165d21e4a to your computer and use it in GitHub Desktop.
Save wrightrocket/3d824b49c0dc18832080aeb165d21e4a to your computer and use it in GitHub Desktop.
.bashrc with some utility functions
# .bashrc
# User specific aliases and functions
alias k='kubectl'
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias hgrep='history|grep'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Use vi editing on the command line by pressing ESC
#set -o vi on
if [ -x /usr/bin/kubectl -o -x /usr/local/bin/kubectl ]
then
source <(kubectl completion bash)
fi
function backup() {
if [ -n "$1" ]
then
source=$1
else
echo 'Provide a path to a file or directory to backup'
echo 'Usage: backup /path/to/file'
echo 'Result is file path extended with date/time stamp'
exit 1
fi
stamp=$( date +%Y%m%d-%H%M%S )
if [ -d "$source" ]
then
cp -a $source $source.$stamp
else
cp $source $source.$stamp
fi
}
function mkcd() {
mkdir -p $1 && cd $1
}
df() {
/usr/bin/df -h $* | grep -vE "docker|tmpfs"
}
function lfget() {
pw=$(cat $HOME/.LFTpw)
wget --user=LFtraining --password=$pw $1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment