Last active
January 2, 2016 06:19
-
-
Save godDLL/8262911 to your computer and use it in GitHub Desktop.
Every shell is a login shell on Mac OS X. And I symlink `.bash_login` to `.bashrc`, so that `.profile` is getting sourced for interactive Bash shells.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
eval printf '%.s-' {1..$COLUMNS} | |
clear |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## General configuration | |
[[ -z $PROFILE_SETUP && -r $HOME/.profile ]] && . $HOME/.profile | |
#shopt -q login_shell && echo this is a login shell | |
## Branch name and status marker for Git repos | |
GIT_DIRTY () { | |
git diff --quiet HEAD &>/dev/null | |
[[ $? == 1 ]] && echo ":" || (echo "·"; false) | |
} | |
GIT_REPO () { | |
local BRANCH | |
BRANCH=$(git symbolic-ref HEAD 2> /dev/null)|| return | |
echo ${BRANCH#refs/heads/} | |
} | |
[[ $TERM != dumb && $BASH ]] && | |
export PS1='\[\033[8;30m\]#$(r=$?;[ $r -ne 0 ]&&printf "\[\033[m\]\[\033[7;30m\]$(date "+%H:%M:%S")\[\033[m\]\[\033[8m\]!\[\033[0;31m\]$r"||printf "\[\033[m\]\u\[\033[0;37m\]@\[\033[0;32m\]\H")\[\033[m\] \W$(REPO=`GIT_REPO`&&DIRTY=`GIT_DIRTY`&&printf "\[\033[0;32m\]$DIRTY\[\033[1;35m\]$REPO"||printf "\[\033[0;37m\]$DIRTY\[\033[0;35m\]$REPO")\[\033[0;34m\]$([ -n "$RANGER_LEVEL" ]&&printf "%%"|| printf "\$")\[\033[m\] ' | |
## Tools and Aliases | |
# replace 's/search/replace' *.text¬ | |
alias replace="find . -name \"$2\" -exec sed -i -r \"$1\" {} \;"¬ | |
alias f='find . -iname' | |
alias g='grep -i' | |
alias r='grep -R' | |
#alias tmux='tmux -u' # Apple sets LC_CTYPE=UTF-8 instead of en_GB.UTF-8 | |
function iman { wget -qO - "http://www.commandlinefu.com/commands/matching/$@/$(echo -n "$@" | openssl base64)/plaintext"; } | |
function pdfman { man -t $1 | open -a /Applications/Preview.app -f; } | |
alias iserver='python -m SimpleHTTPServer 7300' | |
alias inotebook='ipython notebook --no-browser --pylab inline --port 7400' | |
alias ibrowser='open -a "Google Chrome Canary" --args --allow-file-access-from-files "$PWD"' | |
function get { | |
# download args OR get args one by one terminated by <CR> | |
[[ -z $@ ]] && { | |
local URL LIST | |
while read URL; do | |
[[ -z $URL ]] && break | |
LIST+=' '$URL | |
done | |
} || LIST=$@ | |
aria2c --check-certificate=false --dir=$HOME/Downloads \ | |
-s30 -j20 -x16 $LIST | |
} | |
## Development and W.I.P | |
export LSCOLORS=hxfxcxdxbxhgedabagacad | |
bind "set completion-ignore-case on" | |
complete -W "$(sort -u ~/.ssh/known_hosts |cut -d ' ' -f1)" ssh | |
alias sd='date "+%Y-%m-%d %H:%M:%S"' | |
alias git-log='git log --pretty=format:"%C(yellow)%h %ad%Cred%d %Creset%s%Cblue [%cn]" --date=relative --decorate -n 10' | |
function ht { if (test -n "$1"); then telnet $1 80; else echo -e "USAGE:\tht DOMAIN.TLD\twill open a telnet session to given site."; fi; } | |
function cl { cd $1; ls -lG; } | |
function lss { [ -n "$1" ] && du -cksh $1/* |sort -rn |head -11 ; } | |
function ssh_proxy { ssh -24gCD *:9999 $1 ; } | |
function ssh_get { ssh $1 "tar zcf - $2" | tar zxf - ; } | |
function git_hack { | |
local CURRENT=`git branch | grep '\*' | awk '{print $2}'` | |
git checkout master | |
git pull origin master | |
git checkout ${CURRENT} | |
git rebase master | |
} | |
function git_ship { | |
local CURRENT=`git branch | grep '\*' | awk '{print $2}'` | |
git checkout master | |
git merge ${CURRENT} | |
git push origin master | |
git checkout ${CURRENT} | |
} | |
## Lastly, include PWD in PATH so as not to type leading ./ | |
PATH+=:. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## General SHELL configuration shared everywhere | |
[[ $PROFILE_SETUP ]] && [[ $$ == $PROFILE_SETUP ]] && exit | |
# Source once per PID | |
PROFILE_SETUP=$$ | |
# /etc/profile uses /usr/libexec/path_helper for this | |
export PATH=/usr/local/bin:${PATH//\/usr\/local\/bin:/} | |
## locale -a for installed options, locale for current | |
# LC_ALL > LC_CTYPE > LANG | |
export LC_CTYPE=en_GB.UTF-8 | |
export TERM=xterm-256color | |
export EDITOR=vim | |
shopt -s expand_aliases | |
# replace 's/search/replace' ./*.text¬ | |
alias replace='perl -pi -w -e "'$1'/g;" "'$2'"'¬ | |
alias h='curl -sIX GET -w "Time-Total: %{time_total} s\n"' | |
alias mkpasswd='openssl rand -base64 16 |cut -c1-13' | |
alias htauth='echo -n \$USER:; openssl passwd -crypt $1 2>/dev/null' | |
#alias boombom='sed -e '1s/^\xef\xbb\xbf//' < $1 > $1.noBOM' | |
maybe () { local DICE=`test -n "$1" && echo $1 || echo 2`; test $(($RANDOM % $DICE)) -eq 0; } | |
if [[ $PS1 ]]; then # Interactive SHELL | |
shopt -s histappend | |
export HISTFILESIZE=5000 | |
export HISTCONTROL=erasedups | |
alias quit='exit' | |
alias ls='ls -G' | |
alias ll='ls -lG' | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment