Skip to content

Instantly share code, notes, and snippets.

@TerDale
Last active September 15, 2020 09:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TerDale/4e7e9c440d726dfa0277 to your computer and use it in GitHub Desktop.
Save TerDale/4e7e9c440d726dfa0277 to your computer and use it in GitHub Desktop.
JMD's bash aliases
#!/bin/bash
# JMD's bash aliases v3.3.5
echo "-- Setting aliases..."
_su(){
if [[ $# == 0 ]]; then
PS1=$PS_ROOT sudo -sE
else
PS1=$PS_OTHERS _SET_ENV="$_SET_ENV" sudo -sE -u "$@"
fi
}
alias su=_su
alias sd=sudo
_ps1 ()
{
if [ -z "${!USER}" ]; then
PS1=$others;
else
PS1=${!USER};
fi
}
alias ps1=_ps1
alias ln='ln -i'
alias cp='cp -i'
alias mv='mv -i'
alias rm='rm -I --preserve-root'
alias ld='ls -d */'
alias chown='chown --preserve-root'
alias chmod='chmod --preserve-root'
alias chgrp='chgrp --preserve-root'
alias get-aliases='\wget $WGET_OPTIONS -t 3 -q -O - "$@" https://gist.githubusercontent.com/TerDale/4e7e9c440d726dfa0277/raw'
fdns() {
dig +short $1 | xargs -L 5 dig +short -x
}
alias fnds='fdns'
alias dig="dig +short"
alias rdig="dig +short -x"
# ???
alias age="sudo tune2fs -l $(df -lh / |(read; awk '{print $1; exit}')) | grep -i created"
alias lmod="stat -c '%A %a %n'"
alias selinux=setenforce
alias userlist='getent passwd | egrep "[a-z]+:[0-9]{3,4}:" | cut -d: -f1,3,4,5 | sort'
alias watch="watch -d -n 1"
function rmh() { sed -i "$1d" ~/.ssh/known_hosts; }
alias wdu="du -shx * |sort -rh |egrep --color=never '(M|G)\s'"
alias nmount='mount |column -t | grep --colour=never -E "type +nfs "'
alias smount='mount |column -t | grep --colour=never -E "type +(cifs)|(smb) "'
alias amount='mount |column -t'
alias nano='nano -BDHOSWkiK'
alias scp='scp -p'
alias cd=pushd
# Typos
alias alais="alias"
alias func+='typeset -f'
alias func='compgen -A function'
ltree()
{
tree -C $* | less -R
}
alias wget='wget --content-disposition'
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar e $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 mcd() {
mkdir -p "$1" && cd "$1";
}
alias ..='cd ..'
alias ...='cd ../../'
alias ....='cd ../../../'
alias .....='cd ../../../../'
alias ......='cd ../../../../../'
alias zgrep='zgrep --color=always'
alias al="alias | grep"
alias netstat='\sudo \netstat -pantu' ps='ps -Hef' pgrep='\pgrep -fl' ll='ls -lrtq --color=tty' time="\time -f '\nreal %es'" ds=wdu mkcd=mcd free='\free -g' df='\df -hl' md='\mkdir' mkd='\mkdir' rd='\rmdir' rmd='\rmdir'
alias ac-thdump='\sudo kill -3 $(\pgrep activecircle)' fdig='fdns' redo='sulast'
alias screenNow="screen -DR"
alias Allc="sudo less /activecircle/cell/data/Log/lastcell.txt"
alias Anlt="sudo nano /activecircle/.locators"
alias Aclt="sudo cat /activecircle/.locators"
alias Anlv="sudo nano /activecircle/.localvars"
alias Aclt="sudo cat /activecircle/.localvars"
alias As="sudo service activecircle "
alias Aclc="sudo chmod o+x /activecircle/cell/data;sudo chmod o+rx /activecircle/cell/data/Log;sudo chmod o+r /activecircle/cell/data/Log/lastcell.txt"
alias sc=systemctl
alias ssc='sudo systemctl'
alias jc='journalctl -xle'
alias sjc='sudo journalctl -xle'
# Define ip alias if -c (color) option supported
ip -c a >/dev/null 2>&1; if [ $? -eq 0 ] ; then alias ip='ip -c -4'; else alias ip='ip -4'; fi
ft() {
find . -name "$2" -exec grep -il "$1" {} \;
}
# Usage: win2lin_path "x:\windows\path"
function win2lin_path() {
sed -e 's#^[a-zA-Z]:##' -e 's#\\#/#g' <<< "$1";
}
echo "-- Done."
@TerDale
Copy link
Author

TerDale commented Jan 26, 2016

JMD's bash aliases

History:

  • v3.3.5 2020-09-15: added amount & smount.
  • v3.3.4 2020-09-03: set ip alias for IPv4 only.
  • v3.3.3 2019-06-11: added sjc, ssc.
  • v3.3.2 2019-06-05: added jc, ip.
  • v3.3.1 2019-06-03: added sc.
  • v3.3 2016-08-05: enhanced ip4 & ip6, added zgrep
  • v3.2.2 2016-07-07: changed sulast
  • v3.2.1 2016-06-23: added Aclc alias to allow "others" to read lastcell.txt
  • v3.2 2016-06-17: added AC aliases: A*
  • v3.1 2016-01-22: fixed winpath(), and renamed it win2lin_path()
  • v3. 2015-09-29: added winpath()
  • v2. Gist-based version
  • v1. alias.sh-based version (alias.sh now closed down)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment