DEV Community

Aniket Kadam
Aniket Kadam

Posted on • Originally published at dev.to on

1

Bash Aliases (aka part 1 of 2000 of how to get more done in less time)

Speed.

It’s one of the most important things in life. Don’t get me wrong, some things must be done slow to be done right. You want to carefully consider choices and decisions but what about the inbetween?

What if you just wanted to know if the internet was down (again) ?

ping 8.8.8.8

What if you wanted to see what your debug key signature is for the millionth time?

keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

Fond embracers of the terminal will be the first to snort approval that the fastest way to do most things, is via the terminal.

However, for the very common commands, you’d hardly want to keep typing them out every time.

Enter the bash aliases,

The most used of my aliases are:

alias e=‘exit’

This tells bash that whenever you type e by itself and press enter, you want it to run the command ‘exit’.

Pretty much anything that can be written in bash, an alias can made for.

TLDR;

Save this file to your home folder and thank me later. The letter after alias, is what you type to run the command after equals.

# Exits the terminal
alias e=exit
# Clears the window so you can see what's going on!
alias c=clear
# Uninstall your current app.
alias u='adb uninstall com.aniket'
# Clear data for the current app.
alias cl='adb shell pm clear com.aniket'
# Show the status of the git project you've cd'd into.
alias s='git status'
# To be used in the pattern sl README.md, to open files in a visual editor when you need to.
alias sl='sublimetext'
# To go to the best place on a computer, the ramdisk.
alias ds='cd /dev/shm/'
# Am I online yet?
alias p='ping 8.8.8.8'
# The only long command to prevent you from triggering it accidentally. Can still be tab completed.
alias undocommit='git reset --soft HEAD^'
# Launch a script in a particular location.
alias t='python ~/gantt.py '
# What's my debug key?
alias debug_key='keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android'
# Log into another machine
alias se='ssh user@192.168.0.81'
# Log into another machine with a different username
alias sea='ssh aniket@192.168.0.81'
# Reinstall your app into something.
alias ir='adb install -r ~/AndroidStudioProjects/MyApp/app/build/outputs/apk/app-release.apk'
# Proguard obfuscated crash logs woes.
alias re='retrace.sh ~/AndroidStudioProjects/MyApp/app/build/outputs/mapping/release/mapping.txt /dev/shm/test.txt'
# See what network tasks are scheduled at your endpoint.
alias gcm='adb shell dumpsys activity service GcmService --endpoints com.aniket.sync.NetworkSchedulerService'
# Launch a deeplink without clicking links
alias deeplink='adb -s 110158c09410334a shell am start -W -a android.intent.action.VIEW -d "aniket://registration" com.aniket'
# Go to your home directory for your current project
alias h='cd /home/nicky/interesting_code/RealmMigrationTest'
# Rebuild your current app.
alias rb='./gradlew clean assembleDebug && adb uninstall com.aniket && adb install -r ./app/build/outputs/apk/app-debug.apk'
# Login to your pi :)
alias pi='ssh pi@192.168.1.95'
# Create an ssh linked folder on your local computer with a folder on the pi
alias pi_folder='sshfs -o idmap=user pi@pi:/media/aniket/flash_drive/documents ~/pi_folder'
# Battery indicator not working? Check our your battery percentage.
alias power='upower -i $(upower -e | grep 'BAT') | grep -E "state|to\ full|percentage"'
view raw .bash_aliases hosted with ❤ by GitHub

What will you be putting in your aliases file? Comment below or reach out to me on twitter at @AniketSMK

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (2)

Collapse
 
brandonwallace profile image
brandon_wallace

Here are some of the aliases and functions I have in my .bashrc.

# View dd progress.
alias dd='dd status=progress '

# Long list almost all files with classification and a humanly-readable size.
function ll(){ 
    ls --color=auto -A -F -l -h --time-style=+"%Y-%m-%d %H:%M:%S"; 
}

# Long listing with the newest files last.
function lt(){ 
    ls --color=auto -A -F -l -h -t -r --time-style=+"%Y-%m-%d %H:%M:%S"; 
}

# Find the biggest files or folders in current directory.
function biggest(){ du -sk * | column -t | sort -nr | head -20; }

# Show current time.
function t(){ date +%H:%M:%S; }

# Grep through history.
function hg(){ history | grep $1; }

alias tree='tree -F --dirsfirst'

alias jan='cal -m 01'
alias feb='cal -m 02'
alias mar='cal -m 03'
alias apr='cal -m 04'
alias may='cal -m 05'
alias jun='cal -m 06'
alias jul='cal -m 07'
alias aug='cal -m 08'
alias sep='cal -m 09'
alias oct='cal -m 10'
alias nov='cal -m 11'
alias dec='cal -m 12'
Enter fullscreen mode Exit fullscreen mode

github.com/brandon-wallace/bashrc/...

Collapse
 
aniketsmk profile image
Aniket Kadam

Nice! Thanks for sharing. Love the calendar.

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more