#!/usr/bin/env bash # Easier navigation: .., ..., ...., ....., ~ and - alias ..="cd .." alias cd..="cd .." alias ...="cd ../.." alias ....="cd ../../.." alias .....="cd ../../../.." alias ......="cd ../../../../.." alias ~="cd ~" # `cd` is probably faster to type though alias -- -="cd -" # TODO: Make this conditional if using termux #? maybe by using pwd (/data/data/com.termux/files) # Shortcuts alias sd="cd /mnt/sdcard" alias dl="cd /mnt/sdcard/Download" alias g="git" alias h="history" alias j="jobs" # alternative to tail -f alias lessf="less +F" # List all files colorized in long format alias l="ls -l" alias ll="ls -lah" # List all files colorized in long format, including dot files alias la="ls -la" # List only directories alias lsd="ls -l | grep --color=never '^d'" # Always use color output for `ls` #alias ls="command ls --color=auto" # Always enable colored `grep` output # Note: `GREP_OPTIONS="--color=auto"` is deprecated, hence the alias usage. alias grep='grep --color=auto' alias fgrep='fgrep --color=auto' alias egrep='egrep --color=auto' # Enable aliases to be sudo’ed alias sudo='sudo ' # Get week number alias week='date +%V' # Stopwatch alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date' # Dice for the undecided alias dice='echo $[ 1 + $RANDOM % 6 ]' alias yn='[ $[ $RANDOM % 2 ] == 0 ] && echo "Yes" || echo "No"' # IP addresses alias myip="dig +short myip.opendns.com @resolver1.opendns.com" alias localip="ifconfig wlan0 | grep 'inet addr' | cut -d ':' -f 2 | cut -d ' ' -f 1" alias ips="ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'" # Canonical hex dump; some systems have this symlinked command -v hd > /dev/null || alias hd="hexdump -C" # URL-encode strings alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1]);"' # Ring the terminal bell alias badge="tput bel" # Intuitive map function # For example, to list all directories that contain a certain file: # find . -name .gitattributes | map dirname alias map="xargs -n1" # Reload the shell (i.e. invoke as a login shell) alias reload="exec $SHELL -l" # See if connection works alias p="ping 1.1.1.1" # Print each PATH entry on a separate line alias path='echo -e ${PATH//:/\\n}'