Skip to content

Instantly share code, notes, and snippets.

@amilner42
Created November 12, 2017 21:33
Show Gist options
  • Save amilner42/7f7cf31ca42a52f38eda01f6b83b5307 to your computer and use it in GitHub Desktop.
Save amilner42/7f7cf31ca42a52f38eda01f6b83b5307 to your computer and use it in GitHub Desktop.
Linux Aliases
# Custom Aliases
alias vimbash='vim ~/Desktop/programming/git/linuxAliases/.bash_aliases' # Alias for editing .bash_aliases (do not copy this directly, change the path to vim ~/.bash_aliases)
alias sourcebash='source ~/.bashrc' # Alias for sourcing the .bashrc file
# Git
alias gitpassmemory="git config --global credential.helper cache --timeout=3600"
alias gitcleanall='gita.a ; git reset --hard HEAD'
alias gitcleanstage='git reset HEAD *'
alias gitinit='git init'
alias gitunstage='git reset HEAD'
alias gitundocom='git reset --soft HEAD^'
alias gitdelcom='git reset --hard HEAD^'
alias gitcleanlocalbranches='git branch --merged | grep -v "\*" | grep -v "master" | grep -v "develop" | grep -v "staging" | xargs -n 1 git branch -d'
# Git Clone
alias gitcl.='git clone'
# Git Log
alias gitl.='git log --pretty=oneline --decorate --graph --all'
# Git remove
alias gitrm.='git rm'
alias gitrm.c='git rm --cached'
# Git remote
alias gitr.='git remote -v'
alias gitr.a='git remote add'
alias gitr.r='git remote rm'
alias gitr.s='git remote show'
alias gitr.p='git remote prune'
# Git Rebase
alias gitrb.='git rebase'
alias gitrb.i='git rebase -i'
alias gitrb.a='git rebase --abort'
alias gitrb.c='git rebase --continue'
# Git status
alias gits.='git status -s'
alias gits.l='git status'
# Git stash
alias gitst.='git stash'
alias gitst.l='git stash list'
alias gitst.s='git stash save'
alias gitst.a='git stash apply'
alias gitst.p='git stash pop'
# Git push
alias gitps.='git push'
alias gitps.f='git push --force'
alias gitps.t='git push --tags'
alias gitps.su='git push --set-upstream'
# Git pull
alias gitpl.='git pull'
alias gitpl.a='git pull --all'
# Git fetch
alias gitf.='git fetch'
# Git diff
alias gitd.='git diff --ignore-space-change'
alias gitd.s='git diff --staged --ignore-space-change'
# Git merge
alias gitm.='git merge'
# Git commit
alias gitc.='git commit -m'
alias gitc.a='git commit --amend -m'
alias gitc.ane='git commit --amend --no-edit'
# Git checkout
alias gitch.='git checkout'
alias gitch.b='git checkout -b'
# Git add
alias gita.='git add'
alias gita.a='git add -A'
# Git branch
alias gitb.='git branch -a'
alias gitb.r='git branch -r'
alias gitb.l='git branch'
alias gitb.d='git branch -d'
alias gitb.D='git branch -D'
# Git tag
alias gitt.='git tag'
alias gitt.a='git tag -a'
# Hub
alias hubhttps='git config --global hub.protocol https'
alias hubcreate='/home/arie/Desktop/programming/hub/hub create'
alias hubbrowse='/home/arie/Desktop/programming/hub/hub browse'
alias hubclone='/home/arie/Desktop/programming/hub/hub clone'
alias hubclonenew='/home/arie/Desktop/programming/hub/hub clone --depth=1'
alias hubfork='/home/arie/Desktop/programming/hub/hub fork'
alias hubcherry='/home/arie/Desktop/programming/hub/hub cherry-pick'
# CD
alias cddart='cd /home/arie/Desktop/programming/languages/dart'
alias cdgodow='cd ~/Desktop/programming/git/goDo/goDoWebApp/'
alias cdgodos='cd ~/Desktop/programming/git/goDo/goDoServer/'
alias cdgit='cd ~/Desktop/programming/git'
alias cddbgen='cd ~/Desktop/programming/git/dbgen'
alias cdlang='cd ~/Desktop/programming/languages'
alias cdpro='cd ~/Desktop/programming/'
alias cdjob='cd ~/Desktop/programming/jobHunt'
alias cdprac='cd ~/Desktop/programming/javaWorkspace/interviewPractice'
alias cdrails='cd ~/Desktop/programming/languages/ruby/rails'
alias cduinternapi='cd ~/Desktop/programming/git/uInternAPI'
alias cdubc='cd ~/Desktop/programming/git/ubcioRepos/'
alias cdradify='cd ~/Desktop/programming/git/radify'
alias cdairfair='cd ~/Desktop/programming/git/radify/airfair'
# Docker
alias docker.l='docker ps'
alias docker.r='docker run'
alias docker.rm='docker rm -fv '
alias docker.i='docker images'
# IDE
alias webstorm="cd /home/arie/Desktop/programming/IDEs/WebStorm-143.1184.19/bin/ ; ./webstorm.sh &"
# Rails
alias be='bundle exec'
alias bi='bundle install'
alias bu='bundle update'
alias pg='sudo su postgres'
alias test='bundle exec rspec'
alias migrate='bundle exec rake db:migrate'
alias status='bundle exec rake db:migrate:status'
alias rollback='bundle exec rake db:rollback'
alias seed='bundle exec rake db:seed'
alias s='rails s'
# Code gen aliases.
alias cg-ng2comp='python ~/Desktop/programming/git/code-gen/code_gen.py --template_name TypescriptAngular2Component --template_args '
alias cg-ng2serv='python ~/Desktop/programming/git/code-gen/code_gen.py --template_name TypescriptAngular2Service --template_args '
alias cg-ng2pipe='python ~/Desktop/programming/git/code-gen/code_gen.py --template_name TypescriptAngular2Pipe --template_args '
alias cg-javatemp='python ~/Desktop/programming/git/code-gen/code_gen.py --template_name JavaTemp'
# SSH
alias ssh-airfair='ssh [email protected]'
# General
alias internet-stats='vnstat'
alias resetPATH='PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
alias ubuntuVersion='lsb_release -a'
alias nm='PATH=$(npm bin):$PATH'
alias js2ts='rename "s/.js$/.ts/" *.js'
alias css2scss='rename "s/.css$/.scss/" *.css'
alias notepad='sudo subl ~/Desktop/privte_notepad'
alias mvuponedir='mv * .[^.]* ..'
alias hsearch='history | grep'
alias psearch='ps -eaf | grep'
alias fbdeploy='firebase deploy'
alias kernal='uname -r'
alias kernals='dpkg -l | grep linux-image'
alias install='sudo apt-get install'
alias clean='sudo apt-get clean'
alias update='sudo apt-get update'
alias remove='sudo apt-get remove'
alias h='haskell-compiler'
alias hi='ghci'
alias matlab='~/Desktop/programming/languages/matlab/matlab &'
alias path='readlink -f'
alias pdf='evince'
alias fuckoff='sudo $(fc -nl -1)'
alias calc='bc --mathlib'
alias c='clear'
alias cl='clear'
alias r='reset'
alias ?='alias'
alias workfe='cdgit; cd code-tidbit-web-client; cd src/'
alias workbe='cdgit; cd code-tidbit-server;'
alias rv='~/Desktop/programming/git/relational-vision/env/bin/python ~/Desktop/programming/git/relational-vision/rv.py'
# Lint aliases
alias cleanpython='pylint --reports=n --disable=deprecated-module'
# ls
alias lsl='ls -lht --color="auto"'
alias lsa='ls -aht --color="auto"'
alias lsla='ls -lhat --color="auto"'
# Custom functions
function countdown(){
date1=$((`date +%s` + $1));
while [ "$date1" -ne `date +%s` ]; do
echo -ne "$(date -u --date @$(($date1 - `date +%s`)) +%H:%M:%S)\r";
sleep 0.1
done
}
function stopwatch(){
date1=`date +%s`;
while true; do
echo -ne "$(date -u --date @$((`date +%s` - $date1)) +%H:%M:%S)\r";
sleep 0.1
done
}
function cs() {
cd $1;
ls;
}
function csl() {
cd $1;
lsl;
}
# Custom functions for making Files/Folders
function makeClasses() {
for var in "$@"
do
cd ~/Desktop;
mkdir $var;
cd $var;
mkdir "assignments";
mkdir "classNotes";
mkdir "readingMaterial";
cd;
done
}
source ~/Desktop/programming/git/linuxAliases/.bash_private_aliases
@amilner42
Copy link
Author

Linux Aliases (in 5 minutes or less)

Linux aliases are awesome, they save you a ton of time and allow you to make any command/sequence-of-commands/function
just a few characters long. I've uploaded my aliases, you might like them so go ahead and take them!

Simply put any aliases you like (feel free to take a look at mine to get some ideas / copy them over) in a .bash_aliases
file in your home directory. To get to your home directory - just type: "cd". To make the bash_aliases file either
use vim/nano or any text editor.
Eg. vim .bash_aliases
(regardless of the text editor, the file name must be exactly that with the period at the front)

Remember that once you add aliases, it won't "load" in the terminal right away, you either can close and reopen the
terminal or you can type: "source ~/.bashrc" but hey...who wants to type that out everytime...so instead just use
my alias "sourcebash" and it'll do that for you! Whenever you think of an awesome alias you wanna add, just use the
alias "vimbash" to get to the .bash_aliases file in vim. If you aren't using aliases...you're missing out!

Enjoy!
(for those curious why source ~/.bashrc refreshes the .bash_aliases file, its because inside the .bashrc file
it runs source .bash_aliases if the file exists. Its good practice to keep your aliases outside of the .bashrc file
and instead in its own .bash_aliases file just to keep things clean)

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