Skip to content

Instantly share code, notes, and snippets.

@bmount
Created February 18, 2016 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmount/3e18cbeb78a7299a823a to your computer and use it in GitHub Desktop.
Save bmount/3e18cbeb78a7299a823a to your computer and use it in GitHub Desktop.
export TERM=xterm-256color
if tput setaf 1 &> /dev/null; then
tput sgr0
if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then
MAGENTA=$(tput setaf 9)
ORANGE=$(tput setaf 172)
GREEN=$(tput setaf 190)
PURPLE=$(tput setaf 141)
WHITE=$(tput setaf 256)
else
MAGENTA=$(tput setaf 5)
ORANGE=$(tput setaf 4)
GREEN=$(tput setaf 2)
PURPLE=$(tput setaf 1)
WHITE=$(tput setaf 7)
fi
BOLD=$(tput bold)
RESET=$(tput sgr0)
else
MAGENTA="\033[1;31m"
ORANGE="\033[1;33m"
GREEN="\033[1;32m"
PURPLE="\033[1;35m"
WHITE="\033[1;37m"
BOLD=""
RESET="\033[m"
fi
function git_info() {
# check if we're in a git repo
git rev-parse --is-inside-work-tree &>/dev/null || return
# quickest check for what branch we're on
branch=$(git symbolic-ref -q HEAD | sed -e 's|^refs/heads/||')
# check if it's dirty (via github.com/sindresorhus/pure)
dirty=$(git diff --quiet --ignore-submodules HEAD &>/dev/null; [ $? -eq 1 ]&& echo -e "*")
echo $WHITE" on "$PURPLE$branch$dirty
}
function set_core_pattern() {
ulimit -c unlimited
sudo bash -c "echo '/tmp/core-%p-%s-%c-%P' > /proc/sys/kernel/core_pattern"
}
# Only show username/host if not default
function usernamehost() {
echo "${MAGENTA}$USER ${WHITE}at ${ORANGE}$HOSTNAME $WHITEin ";
}
PS1="\[\e]2;$PWD\[\a\]\[\e]1;\]$(basename "$(dirname "$PWD")")/\W\[\a\]${BOLD}\$(usernamehost)\[$GREEN\]\w\$(git_info)\[$WHITE\]\n\$ \[$RESET\]"
gg_replace() {
if [[ "$#" == "0" ]]; then
echo 'Usage:'
echo ' gg_ireplace term replacement file_mask'
echo
echo 'Example:'
echo ' gg_ireplace cappuccino Cappuccino *.html'
echo
else
find=$1; shift
replace=$1; shift
ORIG_GLOBIGNORE=$GLOBIGNORE
GLOBIGNORE=*.*
if [[ "$#" = "0" ]]; then
set -- ' ' $@
fi
while [[ "$#" -gt "0" ]]; do
for file in `git grep -Fil $find -- $1`; do
perl -pi -w -e "s!\Q$find\E!$replace!gi;" $file
done
shift
done
GLOBIGNORE=$ORIG_GLOBIGNORE
fi
}
restore_submodules() {
git config -f .gitmodules --get-regexp '^submodule\..*\.path$' |
while read path_key path
do
url_key=$(echo $path_key | sed 's/\.path/.url/')
url=$(git config -f .gitmodules --get "$url_key")
git submodule add $url $path
done
}
export GOROOT=$HOME/.tools/go
export GOPATH=$HOME/.tools/gopath
export PATH=$GOPATH/bin:$PATH
export PATH=$HOME/.tools/bin:$GOROOT/bin:$HOME/.tools/ruby/bin:$HOME/.nodejs/bin:$PATH:$HOME/.tools/android-sdk-linux/tools:$HOME/.tools/ffmpeg-static/ffmpeg-2.7.1-64bit-static
export PYTHONPATH=$PYTHONPATH:$HOME/.tools/caffe/python
alias genopencv='cmake -DBUILD_EXAMPLES:BOOL="1" -DWITH_TBB:BOOL="1" -DCMAKE_BUILD_TYPE=RELEASE -D -G "Unix Makefiles" ../..'
alias f=fzf
#export HISTFILESIZE=10000
HOSTNAME="$(hostname)"
HOSTNAME_SHORT="${HOSTNAME%%.*}"
his ()
{
grep -r "$@" ~/.history
history | grep "$@"
}
export HISTFILESIZE=10000
export HISTFILE="${HOME}/.history/$(date -u +%Y/%m/%d.%H.%M.%S)_${HOSTNAME_SHORT}_$$"
mkdir -p $(dirname $HISTFILE)
complete -o default -o nospace -W "$(grep -i -e '^host ' ~/.ssh/config | awk '{print substr($0, index($0,$2))}' ORS=' ')" ssh scp sftp
alias srv='python -m SimpleHTTPServer'
alias lt='ls -Alhtr'
alias pbcopy='xsel --clipboard --input'
alias pbpaste='xsel --clipboard --output'
export CUDA_HOME=/usr/local/cuda-7.5
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:/home/bvm/ips/gpu/cudnn-6.5-linux-x64-v2/:$LD_LIBRARY_PATH
export PATH=${CUDA_HOME}/bin:${PATH}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment