List of useful bash aliases - Productivity - https://labbots.com/my-favorite-bash-aliases-that-increases-productivity/
#lists contents of current directory with file permisions | |
alias ll='ls --color -l -sort' | |
#list all directories in current directories | |
alias ldir='ls -l | grep ^d' | |
# List directory and pipe output to less. Makes viewing of large directory easy | |
alias lsl="ls -lhFA --color | less -r" | |
#Find files in current directory | |
alias fhere="find . -name " | |
#self explanatory | |
alias ..='cd ..' | |
alias ...='cd ../../' | |
#Opens current directory in a file explorer | |
alias explore='nautilus .' | |
#Opens current directory in a file explorer with super user privileges | |
alias suexplore='sudo nautilus .' | |
#Opens current directory in Ubuntu's Disk Usage Analyzer GUI with super user privileges in the background | |
alias analyze='gksudo baobab . &' | |
#Opens a GUI text editor in the background. Can obviously be replaced with your favorite editor | |
alias text='gedit &' | |
#Same as above with super user privileges | |
alias sutext='gksudo gedit &' | |
#Opens a file with whatever program would open by double clicking on it in a GUI file explorer | |
#Usage: try someDocument.doc | |
alias try='gnome-open' | |
#show aliases | |
alias al='echo "------------Your aliases------------";alias' | |
alias a='bash ~/bash_aliases_help.sh --color=true | less -r' | |
#Edit Aliases | |
alias via='gksudo gedit ~/.bash_aliases &' | |
#Apply changes to aliases | |
alias sa='source ~/.bash_aliases;echo "Bash aliases sourced."' | |
#Get Public IP address | |
alias ip='curl icanhazip.com' | |
alias iploc="curl -s http://whatismycountry.com/ | sed -n 's|.*> *\(.*\)</h3>|\1|p'" | |
alias ipinfo='curl ipinfo.io' | |
# Search process table | |
alias psg="ps aux | grep -v grep | grep -i -e VSZ -e" | |
#Restart network manager | |
alias netstart='sudo /usr/sbin/service network-manager restart' |
#!/bin/bash | |
PROGNAME=${0##*/} | |
SHORTOPTS="c::" | |
LONGOPTS="color::" | |
set -o errexit -o noclobber -o pipefail | |
OPTS=$(getopt -s bash --options $SHORTOPTS --longoptions $LONGOPTS --name $PROGNAME -- "$@" ) | |
eval set -- "$OPTS" | |
# Variable for color option. Default to 2 (0 = false, 1 = true, 2 = auto) | |
color=2 | |
# Variable to store if the command is run from terminal | |
istty=0 | |
# Variable to store if the terminal supports color | |
colorsupport=0 | |
while true; do | |
case "$1" in | |
-c | --color ) | |
case "$2" in | |
"" ) color=2 ; shift 2 ;; | |
"true" | "=true" ) color=1 ; shift 2 ;; | |
"auto" | "=auto" ) color=2 ; shift 2 ;; | |
"false" | "=false" ) color=0 ; shift 2 ;; | |
esac ;; | |
-- ) shift; break ;; | |
* ) break ;; | |
esac | |
done | |
# check if stdout is a terminal... | |
if test -t 1 && test $color -ne 0; then | |
istty=1 | |
# see if it supports colors... | |
ncolors=$(tput colors) | |
if test -n "$ncolors" && test $ncolors -ge 8; then | |
colorsupport=1 | |
fi | |
fi | |
if [[ ( $color -eq 2 && $istty -eq 1 && $colorsupport -eq 1 ) || $color -eq 1 ]] ; then | |
txtund=$(tput sgr 0 1) # Underline | |
txtbld=$(tput bold) # Bold | |
bldred=${txtbld}$(tput setaf 1) # red | |
bldblue=${txtbld}$(tput setaf 4) # blue | |
bldbluelight=${txtbld}$(tput setaf 33) # blue | |
bldyellow=${txtbld}$(tput setaf 11) # yellow | |
bldgreen=${txtbld}$(tput setaf 2) # green | |
bldcyan=${txtbld}$(tput setaf 6) # cyan | |
bldwhite=${txtbld}$(tput setaf 7) # white | |
txtrst=$(tput sgr0) | |
alscmd=${bldyellow} | |
alsoption=${bldcyan} | |
header=${txtund}${bldbluelight} | |
fi | |
echo "${header}Bash alias operation${txtrst}" | |
echo "${alscmd}a${txtrst} - show aliases" | |
echo "${alscmd}al${txtrst} - show the commands behind the aliases" | |
echo "${alscmd}via${txtrst} - Edit Aliases" | |
echo "${alscmd}sa${txtrst} - Apply changes to aliases" | |
echo | |
echo "${header}Directory & File operation${txtrst}" | |
echo "${alscmd}ll${txtrst} - Lists contents of current directory with file permisions" | |
echo "${alscmd}ldir${txtrst} - list all directories in current directories" | |
echo "${alscmd}lsl${txtrst} - List directory and pipe output to less. Makes viewing of large directory easy" | |
echo "${alscmd}fhere${txtrst} - Find files in current directory" | |
echo "${alscmd}..${txtrst} - Move one level up the folder" | |
echo "${alscmd}...${txtrst} - Move two level up the folder" | |
echo | |
echo "${header}GUI operations${txtrst}" | |
echo "${alscmd}explore${txtrst} - Opens current directory in a file explorer" | |
echo "${alscmd}suexplore${txtrst} - Opens current directory in a file explorer with super user privileges" | |
echo "${alscmd}analyze${txtrst} - Opens current directory in Ubuntu's Disk Usage Analyzer GUI with super user privileges in the background" | |
echo "${alscmd}text${txtrst} - Opens a GUI text editor in the background. Can obviously be replaced with your favorite editor" | |
echo "${alscmd}sutext${txtrst} - Same as above with super user privileges" | |
echo "${alscmd}try${txtrst} - Opens a file with whatever program would open by double clicking on it in a GUI file explorer" | |
echo | |
echo "${header}IP check${txtrst}" | |
echo "${alscmd}ip${txtrst} - Get Public IP address" | |
echo "${alscmd}iploc${txtrst} - Get your IP location" | |
echo "${alscmd}ipinfo${txtrst} - Get complete information about your public IP address" | |
echo | |
echo "${header}Process Management${txtrst}" | |
echo "${alscmd}psg${txtrst} ${alsoption}<search_key>${txtrst} - Search process table" | |
echo | |
echo "${header}Network operations${txtrst}" | |
echo "${alscmd}netstart${txtrst} - Restart network manager" | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment