Showing posts with label alias. Show all posts
Showing posts with label alias. Show all posts

Sunday, August 31, 2014

My Git Aliases

A git alias gives you the ability to run a long or hard-to-remember git command using a simple name. They are configured in your .gitconfig file.

One of my favourite aliases is git ls which lists all your commits in a nice format. In addition, git ll shows you what files were committed in each commit.

My git aliases are shown below. (For the latest version of my .gitconfig, visit my GitHub dotfiles repository):

[alias]
    st = status
    co = checkout
    br = branch
    df = diff
    ci = commit
    ca = commit -a --amend -C HEAD
    desc = describe
    rb = rebase -i master --autosquash
    cp = cherry-pick

    who = shortlog -s --
    ls = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)[%an]%Creset' --abbrev-commit --date=relative
    ll = log --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)[%an]%Creset' --decorate --numstat
    ld = log --pretty=format:'%C(red)%h %Cgreen%ad%C(yellow)%d %Creset%s%C(bold blue) [%cn]%Creset' --decorate --date=short

    # list aliases
    la = "!git config -l | grep alias | cut -c 7-"

If you have any useful aliases, please share them in the comments section below.

You might also like:
My Bash Profile
My Bash Aliases

Friday, March 11, 2011

My Bash Profile - Part II: Aliases

An alias gives you the ability to run a long or cryptic command using a simple name. The syntax is alias name='command' which means that whenever you type name, Bash will substitute command in its place. For example: alias ll='ls -ltr'. You can't use arguments in an alias command. If arguments are needed, a shell function should be used.

To see what aliases are currently defined use the alias command. To disable an alias in your current shell, use unalias name. You can also disable an alias in your current command by prefixing the alias name with a \. For example: \ls.

Update: My dotfiles are now in Git. For the latest version, please visit my GitHub dotfiles repository.

Here is a list of my Bash aliases taken from ~/.bash_aliases

# reloads profile
alias reload='. ~/.bash_profile'

# edit and source aliases file
alias va='vi ~/.bash_aliases; source ~/.bash_aliases && echo "aliases sourced"'

# go up multiple levels
# (also see 'up' function)
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias ......='cd ../../../../..'
alias cdhist='dirs -v'

# concise date
alias d='date +%Y%m%d-%H%M'

# various ls shortcuts
alias ls='ls -F --color=auto'
alias l='ls'
alias la='ls -a'
alias ll='ls -ltr'
alias lu='ls -ltur'
alias lal='ls -altr'
alias sl='ls'

# list dirs only
alias ldir='ll -d */'

# less with ignore-case, long-prompt and quit-if-one-screen
alias less='less -iMF'

# more is less
alias more='less'
alias mroe='more'
alias m='more'

alias h='history'

# execute last command
# 'r cc' runs the last command beginning with "cc"
alias r='fc -s'

alias igrep='grep -i'
alias rgrep='grep -r'
alias ftail='tail -f'

# fast scp
alias scp='scp -o StrictHostKeyChecking=no -c arcfour -o Compression=no'

# ps with wide output so you can see full commands
alias fullps='ps -auxwww'

# shows all declared functions
alias functions='declare -F'

# autosys aliases. All start with "job".
alias jobls='autorep -J'
alias jobll='autorep -q -J'
alias jobstart='sendevent -E FORCE_STARTJOB -J'
alias jobhold='sendevent -E JOB_ON_HOLD -J'
alias jobice='sendevent -E JOB_ON_ICE -J'
alias jobkill='sendevent -E KILLJOB -J'
alias joboffhold='sendevent -E JOB_OFF_ICE -J'
alias joboffice='sendevent -E JOB_OFF_ICE -J'
alias jobhist='jobrunhist -j'
alias jobdepends='job_depends -c -J'
alias jobsu='sendevent -E CHANGE_STATUS -s SUCCESS -J'
alias jobterm='sendevent -E CHANGE_STATUS -s TERMINATED -J'
If you have any useful aliases, please share them in the comments section below.

More posts on my Bash profile: