Skip to content

Instantly share code, notes, and snippets.

@nitriques
Last active June 1, 2019 19:01
Show Gist options
  • Save nitriques/5966475 to your computer and use it in GitHub Desktop.
Save nitriques/5966475 to your computer and use it in GitHub Desktop.
My .bash_profile files. OS X, Windows (git bash) and Linux (Ubuntu/Cent OS)
alias l='ls -CF'
alias home='cd ~/'
alias apt-get='aptget'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias o='nautilus .'
alias c='xdg-open'
alias vi='vim'
alias profile='vi ~/.bash_aliases'
alias disku='du -s -h'
alias nst='netstat -lntp'
alias kernels='dpkg --list | grep linux-image-3'
# ubuntu update
export DEBIAN_FRONTEND=noninteractive
alias update='sudo apt-get update -y && sudo apt-get upgrade -y && sudo apt-get upgrade -y linux-generic linux-headers-generic linux-image-generic && nvm install 7 && nvm install 6 && nvm install 8'
alias install='sudo dpkg -i'
tabs 4
alias grp='grep -B 2 -A 2 -n --color'
alias l='ls --color=auto -F'
alias ls='ls --color=auto'
alias la='l -Gh'
alias ll='ls -alFh'
alias reload='source ~/.bash_profile'
alias ..='cd ..'
alias ...='..;..'
alias cd..='cd ..'
alias home='cd ~'
alias ~='cd ~'
alias cd-='cd -'
function t {
z $@ trunk
}
# this function calls top with a command filter (1st arg)
# other parameters are passed down to top
function topp {
pattern=$1
shift 1
top -p $(pgrep -d',' $pattern) $@
}
# http header
alias hh='curl -Is'
# base 64
function 64d {
node -e "console.log(new Buffer(process.argv[1], 'base64').toString())" $@
}
function 64e {
node -e "console.log(new Buffer(process.argv[1]).toString('base64'))" $@
}
# php lint all
alias phplint='for D in **/*.php; do php -l $D; done;'
# extension change
function ext {
if [ -z "$1" ]; then
echo "Missing 1st paramter (old ext)"
return 1
elif [ -z "$2" ]; then
echo "Missing 2nd paramter (new ext)"
return 2
fi
find . $3 -name "*.$1" |while read f; do
$4 mv "$f" "${f%.$1}.$2"
done
}
# php lint dirty files
alias ldp="gs | grep ' M' | awk '/ M (.+)/ { system(\"php -l \" \$2); }'"
alias gs='git status -sb'
alias gc='git commit -v'
alias gca='gc -a'
alias gcm='gca -m'
alias gco='git checkout'
alias gwack='git reset --hard HEAD~1'
alias gd='g --no-pager diff'
alias gds='gd --staged'
alias gdw='gd --ignore-space-change --ignore-space-at-eol'
alias gdp='git diff'
alias gb='git branch'
alias g='git'
alias gut='git'
alias gp='git pulls'
alias gf='git fetch'
alias gfa='gf --all'
alias gpo='gp origin'
alias gf='g fetch'
alias gfo='gf origin'
alias gdev='gpo dev'
alias gl="git log --all --graph --pretty=format:'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"
function gcat {
git cat-file -t $1 && git cat-file -p $@
}
# git checkout pull request
# gcopr upstream 22
function gcopr {
git fetch $1 pull/$2/head:pr-$2
git checkout pr-$2
}
# show files in a commit
function gsf {
git diff-tree --no-commit-id --name-only -r $@
}
# show commit content
function gsc {
gd $1^1 $1 "${@:2}"
}
function gt {
v=$1
git tag -a $1 -m "Version ${v}" $2 $3
echo "Version ${v} created"
}
# checkout remote gcor origin branch
function gcor {
gco -b $2 $1/$2
}
# gpt upstream
function gpt {
git push $1 --tags
}
# create release signed commit and signed anotated tag
function grel {
v=$1
gcm "Release ${v}" -S
gt $1 -s
}
# removes a file from the staging area and check it out
function greco {
g reset -- $1;
gco $1;
echo "Checked out" $1
}
# push to both origin and upstream
function gpa {
g push upstream $@;
g push origin $@;
}
alias gim='~/git-imerge/git-imerge'
export CLICOLOR=1
export EDITOR=ex
export VISUAL=vim
alias o='open -a Finder .'
alias s='open -a "Sublime Text" .'
alias home='cd ~/'
alias doc='cd ~/Documents'
alias c='open -a "Google Chrome"'
alias ss='svn status'
alias ssm='ss | grep "^[MAD]"'
alias sc='svn commit -m'
alias sup='svn up'
alias svn-clean="svn status | grep '^?' | awk '{print $2}' | xargs rm -rf"
alias svn-add="svn st | grep '^?' | sed 's/^[? ]*/\"/' | sed 's/$/\"/' | xargs svn add"
alias svn-ignore="svn propedit svn:ignore"
function sd {
svn diff $@ | colordiff
}
function sdw {
sd -x -w $@
}
function svnlol {
svn log $@ | perl -l40pe 's/^-+/\n/'
}
alias scr='svn commit --non-recursive -m'
alias sup.='sup'
alias sup¸='sup'
alias sup^='sup'
alias suo='sup'
alias o='start explorer .'
alias np='start "" "C:\Program Files (x86)\Notepad++\notepad++.exe" '
alias subl='start "" "C:\Program Files\Sublime Text 3\sublime_text.exe" '
alias sub2='start "" "C:\Program Files\Sublime Text 2\sublime_text.exe" '
alias c='start "" "C:\Program Files\Google\Chrome\Application\chrome.exe" '
alias profile='np ~/.bash_profile'
alias s='subl .'
alias ab='start "" //B //WAIT "C:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin\ab.exe" '
export SVN_EDITOR='"C:\Program Files\Git\usr\bin\vim.exe"'
alias ncu='winpty ncu.cmd'
alias w='cd workspace/assets/'
alias b='.. && ..'
alias v='cat package.json | jq .version'
alias bn='cat build.json | jq .lastBuild'
alias build='w;grunt;v;bn;b'
alias buildpush='sup;w;grunt build push --force;v;bn;b'
# terminal title
export PROMPT_COMMAND='echo -ne "\033]0; ${PWD##*/}\007"'
# terminal prompt
export PS1="\e[0;33m->\e[m \u \w\$(git-radar --bash) $ "
# Grunt auto-completion
eval "$(grunt --completion=bash)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment