Created
September 11, 2019 05:20
-
-
Save andrewnicols/11252608a7138ccab2bf1a4a877fd9fb to your computer and use it in GitHub Desktop.
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
############################################################################ | |
# History control | |
############################################################################ | |
# don't put duplicate lines in the history. See bash(1) for more options | |
export HISTCONTROL=ignoredups | |
export HISTSIZE=2000 | |
export HISTFILESIZE=2000 | |
ulimit -Sn 45000 | |
# ... and ignore same sucessive entries. | |
export HISTCONTROL=ignoreboth | |
# Make bash append rather than overwrite history on disk | |
shopt -s histappend | |
############################################################################ | |
# Window control | |
############################################################################ | |
# check the window size after each command and, if necessary, | |
# update the values of LINES and COLUMNS. | |
shopt -s checkwinsize | |
############################################################################ | |
# lesspipe to make life sane | |
############################################################################ | |
# make less more friendly for non-text input files, see lesspipe(1) | |
lesspipelocation=`which lesspipe` | |
[ -x "$lesspipelocation" ] && eval "$(lesspipe)" | |
############################################################################ | |
# Get some bash completion | |
############################################################################ | |
if [ -f /usr/local/etc/bash_completion ] | |
then | |
. /usr/local/etc/bash_completion | |
fi | |
#if [ -f ~/git/ext/SFConsole/console_completion.sh ] | |
#then | |
#. ~/git/ext/SFConsole/console_completion.sh | |
#fi | |
if [ -d /usr/local/bin ] | |
then | |
export PATH=/usr/local/bin:$PATH | |
fi | |
if [ -d /usr/local/sbin ] | |
then | |
export PATH=/usr/local/sbin:$PATH | |
fi | |
if [ -d "${HOME}/git/andrewnicols/chromedriver-wrapper/bin" ] | |
then | |
export PATH="${HOME}/git/andrewnicols/chromedriver-wrapper/bin":$PATH | |
fi | |
if [ -d /usr/local/texlive/2012/bin/universal-darwin ] | |
then | |
export PATH=$PATH:/usr/local/texlive/2012/bin/universal-darwin | |
fi | |
if [ -d /usr/local/opt/python/libexec/bin ] | |
then | |
export PATH=/usr/local/opt/python/libexec/bin:$PATH | |
fi | |
if [ -d /Users/nicols/.mozbuild/git-cinnabar ] | |
then | |
export PATH="/Users/nicols/.mozbuild/git-cinnabar:$PATH" | |
fi | |
############################################################################ | |
# Personal bin directories | |
############################################################################ | |
if [ -d $HOME/bin ] | |
then | |
export PATH=$HOME/bin:$PATH | |
fi | |
if [ -d $HOME/git/bin ] | |
then | |
export PATH=$HOME/git/bin:$PATH | |
fi | |
if [ -d $HOME/.composer/vendor/bin ] | |
then | |
export PATH=$HOME/.composer/vendor/bin:$PATH | |
fi | |
if [ -d $HOME/git/ext/depot_tools ] | |
then | |
export PATH=$HOME/git/ext/depot_tools:$PATH | |
fi | |
source ~/integration/tools/bashrc | |
############################################################################ | |
# Some nice things for this host type | |
############################################################################ | |
case $(uname) in | |
Linux) | |
alias ls='ls -F --color' | |
alias ll='ls -lF --color' | |
alias la='ls -Al --color' | |
;; | |
*) | |
;; | |
esac | |
# Alias git to use hub (hub.github.com). | |
alias git='hub' | |
alias gd='git d' | |
alias gdc='git dc' | |
alias gc='git clean -df' | |
alias gfo='git fetch origin' | |
alias grm='git rebase origin/master' | |
alias gg='git grep' | |
alias gn='git clone' | |
alias g='git' | |
alias gl='git l' | |
alias gb='git hub' | |
alias klg='git log --graph --format="%C(yellow)%h%Creset [%aN]%Cgreen%d%Creset% s" --all' | |
alias vi='vim' | |
alias s='shifter' | |
moodlepath="~/Public/loganberry.local/public_html" | |
alias sm="cd $moodlepath/stable_master" | |
alias s25="cd $moodlepath/stable_25" | |
alias s24="cd $moodlepath/stable_24" | |
alias xphp="xphp`php -v | head -1 | awk '{print $2}' | sed -e 's/\.//' -e 's/\..*//'`" | |
alias xphp="`which php` -dzend_extension=/usr/local/opt/php@`php -r 'echo PHP_MAJOR_VERSION . \".\" . PHP_MINOR_VERSION;'`/pecl/`phpize -v | grep 'Zend Module' | sed 's/^.*: *//'`/xdebug.so" | |
############################################################################ | |
# Project aliases | |
############################################################################ | |
alias y='cd ~/git/yui/yui3' | |
alias m='cd ~/git/moodle' | |
alias mc='cd /private/srv/www/loganberry.local/public_html/useful/moodlecloud' | |
############################################################################ | |
# Some other handy environment variables | |
############################################################################ | |
export EDITOR=vim | |
export EMAIL='andrew@nicols.co.uk' # Used by debchange | |
############################################################################ | |
# If we're not running interactively, then stop processing | |
############################################################################ | |
[ -z "$PS1" ] && return | |
# If this is an xterm set the title to user@host:dir | |
case "$TERM" in | |
xterm*|rxvt*) | |
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"' | |
;; | |
*) | |
;; | |
esac | |
############################################################################ | |
# Shell History | |
############################################################################ | |
# Make bash append rather than overwrite history on disk | |
shopt -s histappend | |
# don't put duplicate lines in the history. | |
HISTCONTROL=ignoredups | |
############################################################################ | |
# Complicated prompt setting... | |
# | |
# We use a specific prompt if we are in a git working directory; | |
# otherwise a standard prompt is chosen. | |
# | |
# This switching is done via PROMPT_COMMAND | |
############################################################################ | |
default_prompt="\! \u@\h:\w> " | |
function get_prompt_command () | |
{ | |
local RED='\[\e[0;31m\]' | |
local YELLOW='\[\e[0;33m\]' | |
local GREEN='\[\e[0;32m\]' | |
local NOCOL='\[\e[0m\]' | |
git_branch=$( parse_git_branch ) | |
if [ -n "$git_branch" ]; then | |
# Set the branch name to green if it's clean, red otherwise. | |
git_clean_p | |
if [[ $? == 0 ]]; then | |
dirstate='clean' | |
if [[ "$git_branch" == "master" ]]; then | |
GITCOLOR=$YELLOW | |
else | |
GITCOLOR=$GREEN | |
fi | |
else | |
dirstate='dirty' | |
GITCOLOR=$RED | |
fi | |
PS1="\! $(path_within_git_repo):$GITCOLOR$git_branch$NOCOL> " | |
echo -ne "]2;${USER}@${HOSTNAME} $git_branch($dirstate) $(path_within_git_repo)" | |
else | |
PS1="$NOCOL$default_prompt" | |
echo -ne "]2;${USER}@${HOSTNAME} `pwd`" | |
fi | |
} | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/' | |
} | |
# This will fail if your directory name contains a '!', but then you | |
# deserve to be flogged anyway. | |
function path_within_git_repo () | |
{ | |
repo_base=$( git rev-parse --git-dir ) | |
if [ "$repo_base" == '.git' ] | |
then | |
# We're in the base repo directory, so git rev-parse has just | |
# given us '.git' | |
repo_base="$(pwd)/$repo_base" | |
fi | |
repo_parent=$( expr "$repo_base" : '\(.*\)/.*/\.git$' ) | |
pwd | sed -e "s!$repo_parent/!!" | |
} | |
# Exit value of 0 if the repo is clean, 1 otherwise | |
function git_clean_p () | |
{ | |
git status | fgrep 'working tree clean' 2>&1 > /dev/null | |
} | |
PROMPT_COMMAND='get_prompt_command' | |
PS2='> ' | |
############################################################################ | |
# Run screen | |
############################################################################ | |
#if [ "$TERM" != "screen" ] | |
#then | |
#exec screen -m | |
#fi | |
f() | |
{ | |
git grep "ion *$1(" | |
} | |
c() | |
{ | |
git grep "class *$1.*{" | |
} | |
fixup() { | |
goback=$1 | |
if [ -z "$goback" ] | |
then | |
goback=2 | |
fi | |
git commit -m 'fixup! MDL' | |
git rebase -i HEAD~"$goback" --autosquash | |
} | |
gf() { | |
hash=$1 | |
if [ -z "$hash" ] | |
then | |
echo "Nope" | |
return | |
fi | |
git commit -c "$hash" | |
} | |
#PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting | |
#source ~/.rvm/scripts/rvm | |
if [ -f ~/git/ext/mdk/extra/goto_instance ]; then | |
. ~/git/ext/mdk/extra/goto_instance | |
. ~/git/ext/mdk/extra/goto_instance.bash_completion | |
fi | |
. ~/git/ext/mdk/extra/bash_completion | |
if [ -d ~/git/ext/depot_tools ] | |
then | |
PATH=~/git/ext/depot_tools:$PATH | |
fi | |
if [ -d ~/bin/instantclient ]; then | |
export ORACLE_HOME="instantclient,~/bin/instantclient" | |
fi | |
_git_cs () { | |
_git_branch | |
} | |
export ANDROID_HOME=/usr/local/opt/android-sdk | |
# added by travis gem | |
[ -f ~/.travis/travis.sh ] && source ~/.travis/travis.sh | |
export NVM_DIR=~/.nvm | |
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm | |
bind '"\e[5C": forward-word' | |
bind '"\e[5D": backward-word' | |
bind '"\e[1;5C": forward-word' | |
bind '"\e[1;5D": backward-word' | |
PATH="/Users/nicols/perl5/bin${PATH:+:${PATH}}"; export PATH; | |
PERL5LIB="/Users/nicols/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB; | |
PERL_LOCAL_LIB_ROOT="/Users/nicols/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT; | |
PERL_MB_OPT="--install_base \"/Users/nicols/perl5\""; export PERL_MB_OPT; | |
PERL_MM_OPT="INSTALL_BASE=/Users/nicols/perl5"; export PERL_MM_OPT; | |
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion | |
if [ -d "$HOME/pse" ] | |
then | |
export PATH=$PATH:$HOME/pse/bin | |
fi | |
if [ -d "$HOME/git/moodle/moodle-docker/bin" ] | |
then | |
export PATH=$PATH:$HOME/git/moodle/moodle-docker/bin | |
fi | |
# added by travis gem | |
[ -f /Users/nicols/.travis/travis.sh ] && source /Users/nicols/.travis/travis.sh | |
eval "$(pyenv init -)" | |
export PATH="$HOME/.mozbuild/arcanist/bin:$HOME/.mozbuild/moz-phab:$PATH" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment