Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 53 additions & 39 deletions bash_aliases
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#!/bin/bash

# General Aliases
alias texclean='rm -f *.toc *.aux *.log *.cp *.fn *.tp *.vr *.pg *.ky'
alias h='history'
alias allh='history | more'
alias hgrep='history | grep'
alias j="jobs -l"

alias c='clear'

# don't alias .
#alias .='cwd

Expand All @@ -18,14 +16,11 @@ alias cd..='cd ..'
#alias cdwd='cd $(bin/pwd)'
alias cwd='echo $PWD'

alias pu="pushd"
alias po="popd"

# File system
alias ln='ln -iv'
alias du='du -h'

# somels aliases, 'l' should my default list command
# some ls aliases, 'l' should my default list command
alias ll='ls -alFh'
alias la='ls -A'
alias l='ls -CFB --hide="*.pyc" --hide="*~"'
Expand All @@ -43,50 +38,25 @@ alias cdopen=xdg-open
# Git
alias g='git'

alias notebook='ipython notebook'
alias pnotebook='ipython notebook --pylab=inline'

# tmux 256 colours
alias tmux='tmux -2'

#
# Csh compatability:
#
alias unsetenv=unset
function setenv () {
export $1="$2"
}

# Irssi is weird on larger screens under tmux
# http://www.wisdomandwonder.com/link/7784/making-irssi-refresh-work-with-tmux
alias irssi='TERM=screen-256color irssi'

# Functions
files () { find ${1} -type f -print ; }
ff () { find . -name ${1} -print ; }
llp () { ls --color=always -lag "$@" | more ; }
word () { fgrep -i "$*" /usr/share/dict/british-english ; }
wordcount () { cat "${1}" | tr -s ' .,;:?\!()[]"' '\012' | \
awk 'END {print NR}' ; }

colour() {
heads=${@:1:$((${#@} - 1))}
tail=${@:${#@}}
pygmentize -f terminal -g $tail | less -R $heads
}

#
# Git
#

git_pull_all ()
{
find -L . -name .git -type d -prune -print0 | xargs -0 -n 1 -I{} bash -c 'echo {}; git -C {}/.. pull; echo'
find -name .git -execdir git pull \;
}

git_checkout_all ()
{
find -L . -name .git -type d -prune -print0 | xargs -0 -n 1 -I{} bash -c 'echo {}; git -C {}/.. checkout $1; git -C {}/.. branch; echo'
find -name .git -execdir git checkout "$1" \;
}

git_remote_state ()
Expand Down Expand Up @@ -141,17 +111,47 @@ palert ()
slack_ping "${type}: ${msg}"
}

echo_passed () {
echo -ne "\e[32m"
cat << 'EOF'
. .
/ `. .' \
.---. < > < > .---.
| \ \ - ~ ~ - / / |
~-..-~ ~-..-~
\~~~\.' `./~~~/
\__/ \__/
/ .- . \
_._ _.- .-~ ~-. / } \/~~~/
_.-'q }~ / } { ; \__/
{'__, / ( / { / `. ,~~| . .
`''''='~~-.__( /_ | /- _ `..-' \\ //
/ \ =/ ~~--~~{ ./| ~-. `-..__\\_//_.-'
{ \ +\ \ =\ ( ~ - . _ _ _..---~
| | { } \ \_\
'---.o___,' .o___,'
EOF
echo -ne "\e[0m"
}

# Vim aliases
# pvim is for running vim in a bash pipeline
alias pvim='vim +":setlocal buftype=nofile" -'
alias pvim_yaml='vim +":setlocal buftype=nofile filetype=yaml" -'
alias pvim_json='vim +":setlocal buftype=nofile filetype=json" -'

goci()
{
shell_pid=$$
running=false

pid_file=$(mktemp --suffix _goci.pid)
trap "rm -f $pid_file" EXIT
trap "rm -f $pid_file && setterm -cursor on" EXIT SIGINT

excludes="${excludes}$(find . \( -path ./vendor -o -path ./.git \) -prune -o -type f -executable -print0 | tr "|" "\|" | tr "\0" "|")"
excludes="${excludes}\..*\.sw[px]$|.git|.*~$|vendor/.*"

setterm -cursor off
clear
inotifywait --quiet --monitor --recursive --exclude "${excludes}" --event modify,create,delete,move --format %f . | stdbuf -oL uniq | while read line
do
Expand All @@ -162,10 +162,22 @@ goci()
echo "'''$line''' changed - building..."
running=true
(
set -xe
go build -v
set -e
go_packages=$(go list ./... | grep -v /vendor/)
echo "Go Packages: $go_packages"
go build $GO_CI_BUILD_ARGS
echo testing...
go test -v $(go list ./... | grep -v /vendor/)
go test -v $go_packages
if command -v golint >/dev/null 2>&1; then
echo linting...
golint -set_exit_status $go_packages
fi
if [ -n "$(type -t echo_passed)" ] && [ "$(type -t echo_passed)" = function ]; then
clear
echo_passed
else
echo "Success!"
fi
) &
echo $! > ${pid_file}
sleep 1
Expand All @@ -174,4 +186,6 @@ goci()
done
}

# Below are functions added with the add-alias command
if [ -f ~/.secret_bash_aliases ]; then
. ~/.secret_bash_aliases
fi
5 changes: 0 additions & 5 deletions bash_profile

This file was deleted.

82 changes: 59 additions & 23 deletions bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color) color_prompt=yes;;
xterm-color|*-256color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
Expand Down Expand Up @@ -150,16 +150,6 @@ if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi

# virtualenvwrapper
# if [ -f /usr/local/bin/virtualenvwrapper.sh ]; then
# export WORKON_HOME=$HOME/.virtualenvs
# export PROJECT_HOME=$HOME/Documents/python
# source /usr/local/bin/virtualenvwrapper.sh
# fi

# Don't write .pyc files
# export PYTHONDONTWRITEBYTECODE=1

# npm
if [ -d ~/.npm-packages ]; then
export NPM_PACKAGES="$HOME/.npm-packages"
Expand All @@ -172,16 +162,38 @@ if [ -d ~/.npm-packages ]; then
MANPATH="$NPM_PACKAGES/share/man:$(manpath)"
fi

# Check if we have SCM branch functions defined
if ! [ -n "$(type -t __git_ps1)" ] && [ "$(type -t __git_ps1)" = function ]; then
__git_ps1() { :; }
fi

# Check if we have kubectx_ps1 functions defined
if ! ([ -n "$(type -t __kubectx_ps1)" ] && [ "$(type -t __kubectx_ps1)" = function ]); then
__kubectx_ps1() {
local printf_format=' [%s]';
local k8sstring

if ! command -v kubectl >/dev/null 2>&1; then
exit
fi
local cur_ctx=$(kubectl config view -o=jsonpath='{.current-context}')

k8sstring="$cur_ctx"

ns="$(kubectl config view -o=jsonpath="{.contexts[?(@.name==\"${cur_ctx}\")].context.namespace}")"
if [[ -n "${ns}" ]]; then
k8sstring="${k8sstring}/${ns}"
fi

printf -- "$printf_format" "$k8sstring"
}
fi

# tmux
if [ -f ~/.tmuxinator.bash ]; then
. ~/.tmuxinator.bash
fi

# Check if we have SCM branch functions defined
if ! [ -n "$(type -t __git_ps1)" ] && [ "$(type -t __git_ps1)" = function ]; then
__git_p1() { :; }
fi

# CPAN stuff
if [ -d ~/perl5 ]; then
PATH="$HOME/perl5/bin${PATH+:}${PATH}"; export PATH;
Expand All @@ -191,7 +203,7 @@ if [ -d ~/perl5 ]; then
PERL_MM_OPT="INSTALL_BASE=$HOME/perl5"; export PERL_MM_OPT;
fi

# Go
# Golang
if command -v go >/dev/null 2>&1; then
export GOPATH="$HOME/.gopath"
mkdir -p $GOPATH
Expand Down Expand Up @@ -222,27 +234,51 @@ if [ -s "$NVM_DIR/nvm.sh" ]; then
: # . "$NVM_DIR/nvm.sh" # This loads nvm
fi

# SSH agent
if [ -z "$SSH_AUTH_SOCK" ] ; then
eval `ssh-agent -s`
ssh-add
fi

# Rust
if [ -d "$HOME/.cargo/bin" ] ; then
PATH="$HOME/.cargo/bin:${PATH}"
export LD_LIBRARY_PATH=$(rustc --print sysroot)/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$(rustc +nightly --print sysroot)/lib:$LD_LIBRARY_PATH
fi
if [ -d "$HOME/.multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/" ] ; then
export RUST_SRC_PATH="$HOME/.multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/"
elif [ -d "$HOME/Documents/rust/rust" ] ; then
export RUST_SRC_PATH="$HOME/Documents/rust/rust/src"
fi
if command -v rustup >/dev/null 2>&1; then
source <(rustup completions bash)
fi

if command -v rg >/dev/null 2>&1; then
export RIPGREP_CONFIG_PATH=$HOME/.ripgreprc
fi

# Emscripten
if [ -d "$HOME/Documents/emscripten" ] ; then
PATH="$HOME/Documents/emscripten/emsdk_portable:$HOME/Documents/emscripten/emsdk_portable/clang/fastcomp/build_incoming_64/bin:$HOME/Documents/emscripten/emsdk_portable/node/4.1.1_64bit/bin:$HOME/Documents/emscripten/emsdk_portable/emscripten/incoming:${PATH}"
fi

# Java

if [ -d "$HOME/.local/gradle-4.2.1" ] ; then
export GRADLE_HOME=$HOME/.local/gradle-4.2.1
export PATH="$GRADLE_HOME/bin:$PATH"
fi

# Python

if [ -d "$HOME/.python3-env" ] ; then
VIRTUAL_ENV_DISABLE_PROMPT=true . $HOME/.python3-env/bin/activate
fi

# Digital Ocean
if command -v doctl >/dev/null 2>&1; then
source <(doctl completion bash)
fi

# SSH agent
if [ -z "$SSH_AUTH_SOCK" ] ; then
eval `ssh-agent -s`
ssh-add
fi

Loading