Last active
September 15, 2020 09:53
-
-
Save TerDale/4e7e9c440d726dfa0277 to your computer and use it in GitHub Desktop.
JMD's bash aliases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
JMD's bash aliases
History:
amount
&smount
.ip
alias for IPv4 only.sjc
,ssc
.jc
,ip
.sc
.ip4
&ip6
, added zgrepsulast
Aclc
alias to allow "others" to readlastcell.txt
A*
winpath()
, and renamed itwin2lin_path()
winpath()