.bash_aliases is as follows
# Useful Alias
# Add an "alert" alias for long running commands. Use like so:
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias killfirefox="pkill -9 firefox"
alias killslack="pkill -9 slack"
alias CD='cd'
[/CODE]
Bash:
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias lh='ls -lh'
# Network Start, Stop, and Restart
alias light='xbacklight -set'
# Apt
alias update='sudo apt -y update'
alias upgrade='sudo apt-get -y update && sudo apt-get -y --allow-unauthenticated upgrade && sudo apt-get autoclean && sudo apt-get autoremove && exit 0'
alias search='sudo apt search'
alias links='links2'
# Install and Remove Packages
alias install='sudo apt-get -y install'
alias uninstall='sudo apt-get --purge autoremove '
alias search-installed='sudo dpkg --get-selections '
alias upgrade-pips='sudo pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 sudo pip install -U
'
#alias cleanPC='sudo apt-get -y autoclean && sudo apt-get -y clean && sudo apt-get -y autoremove'
alias lsdir='ls -ld */'
alias display='eog -w'
alias emptyDir='find . -empty -type d -delete'
alias meng='cd ${HOME}/Dropbox/MEng_Stuff/MEng-Progress'
alias media='sshfs -o reconnect media@192.168.1.10:/mnt /home/"${USER}"/mnt/media_srv'
alias reboot='sudo shutdown -r now'
alias shutdown='sudo shutdown -h now'
alias paux='ps aux | grep'
alias cd.='cd ..'
alias ..='cd ..'
alias ...='cd ../../../'
alias ....='cd ../../../../'
alias .....='cd ../../../../'
alias .4='cd ../../../../'
alias .5='cd ../../../../..'
alias cd..='cd ..'
alias youtube="youtube-dl"
.bash_functions as follows:
[CODE=bash]
# Useful Function
function commiter() {
# Add file, commit and push
git add -f "$1";
if [ "$2" == "" ]; then
git commit -m"Updated $1";
else
git commit -m"$2";
fi;
$(git push -q >> /dev/null 2>&1) &
}
function ssh() {
# Always ssh with -X
command ssh -X "$@"
}
function rsync(){
command rsync --progress "$@"
}
function extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
function psgrep() {
if [ ! -z $1 ] ; then
echo "Grepping for processes matching $1..."
ps aux | grep $1 | grep -v grep
else
echo "!! Need name to grep for"
fi
}
#source $HOME/.opt/Xilinx/Vivado/2017.2/settings64.sh
#source $HOME/.opt/Vivado/2018.1/settings64.sh
#export YOCTODIR=$HOME/Documents/Xilinx/EmbeddedLinux/Yocto/poky
#export PETADIR=$HOME/Documents/Xilinx/EmbeddedLinux/Petalinux
function cd {
# The 'builtin' keyword allows you to redefine a Bash builtin without
# creating a recursion. Quoting the parameter makes it work in case there are spaces in
# directory names.
builtin cd "$@"
# if [ "$PWD" == "$YOCTODIR" ] ;
# then
# bash $YOCTODIR/.source_yocto
# elif [ "$PWD" == "$PETADIR" ] ;
# then
# bash $PETADIR/.source_petalinux
# else
ls -thor ;
# fi
}
function pip() {
if [[ "$1" == "install" ]]; then
shift 1
command pip install --no-cache-dir -U "$@"
else
command pip "$@"
fi
}
#function sudo() {
# if [[ "$1" == "su" ]]; then
# shift 1
# printf "$(tput smso)$(tput setaf 1) [*** With great power comes great responsibility ***] $(tput sgr0)\n\n\n"
# command sudo bash -l
# else
# command sudo "$@"
# fi
#}
git_branch () {
# Get current Git branch
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
git_last_update () {
# Get last update on current Git branch
git log 2> /dev/null | head -n 3 | grep ^Date | cut -f4- -d' ';
}
export PS1="\[\033[0;32m\]\[\033[0m\033[0;38m\]\u\[\033[0;36m\]@\[\033[0;36m\]\h:\w\[\033[0;32m\] \$(git_branch) \$(git_last_update)\n\[\033[0;32m\]└─\[\033[0m\033[0;31m\] [\D{%F %T}] \$\[\033[0m\033[0;32m\] >>>\[\033[0m\] "
function disconnect() {
# Disconnect all mounted disks
for DIR in $(ls "${HOME}/mnt"); do
/bin/fusermount -u -z "${DIR}" || true
done
}
function connectSSHFS(){
if timeout 2 ping -c 1 -W 2 192.168.4.23 &> /dev/null; then
timeout 2 sshfs -o reconnect,ServerAliveInterval=5,ServerAliveCountMax=5 \
192.168.4.23:/ /home/"${USER}"/mnt/dbelab04 &>/dev/null ;
else
fusermount -u -z ~/mnt/dbelab04 ;
fi
}
function dbelab06mount(){
if timeout 2 ping -c 1 -W 2 192.168.4.14 &> /dev/null; then
timeout 2 sshfs -o reconnect,ServerAliveInterval=5,ServerAliveCountMax=5 \
192.168.4.14:/ /home/"${USER}"/mnt/dbelab06 &>/dev/null ;
else
fusermount -u -z ~/mnt/dbelab06 ;
fi
}
function cmc2mount(){
if timeout 2 ping -c 1 -W 2 10.103.254.3 &> /dev/null; then
timeout 2 sshfs -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3 \
"${USER}"@10.103.254.3:/ /home/"${USER}"/mnt/cmc2 &>/dev/null
else
fusermount -u -z ~/mnt/cmc2 ;
fi
}
function cmc3mount(){
if timeout 2 ping -c 1 -W 2 10.103.254.6 &> /dev/null; then
timeout 2 sshfs -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3 \
"${USER}"@10.103.254.6:/ /home/"${USER}"/mnt/cmc3 &>/dev/null
else
fusermount -u -z ~/mnt/cmc3 ;
fi
}
# Add an "alert" alias for long running commands. Use like so:
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias killfirefox="pkill -9 firefox"
alias killslack="pkill -9 slack"
alias CD='cd'
[/CODE]