aboutsummaryrefslogtreecommitdiff
path: root/.bashrc
blob: a246c5fd1e75ec796bd14819ed26e72f9b87e2f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#
# ~/.bashrc
#

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

# History size
HISTSIZE=1000000

# generic setup
function parse_git_branch () {
    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}

# mkdir and follow into dir
function mkdirf () {
    mkdir -p $1 && cd $1
}

# Customize prompt
if [ -n "$SSH_CLIENT" ]; then ssh_text="ssh"
fi
if [ -z $STY ]; then
    export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h\[\033[36;1m\]#$ssh_text\[\033[32m\]:\[\033[33;1m\]\W\[\033[m\]\[\033[34;1m\]\$(parse_git_branch)\[\033[m\]$ "
else
    export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]$STY\[\033[36;1m\]#$ssh_text\[\033[32m\]:\[\033[33;1m\]\W\[\033[m\]\[\033[34;1m\]\$(parse_git_branch)\[\033[m\]$ "
fi

# Alias
alias sr='screen -r'
alias sls='screen -ls'
alias diff='colordiff'
alias e='emacsclient -t'
alias se='sudo emacs -nw'
alias vi='vim'
alias wip='git add -A && git commit -m \"wip\"'
alias etags='etags .*{c,C,cc,cpp,h,hh,hpp,cpp}'
alias r='rg'
alias grep='grep --color'
alias g='googler'
alias pt='prototool'
alias t='tmux'

export ALTERNATE_EDITOR=""
export EDITOR="vim"
export VISUAL=emacs

# NOTE: These env vars happen to be wanted. This also happens to fix a weird bug (just for reference):
# This is a hack to avoid sbt/scala jline error introduced in the latest ncurses update
# Ticket: https://github.com/sbt/sbt/issues/3240
#export TERM=xterm-256color
#export TERMCAP=


# if Mac
if [ "$(uname)" = "Darwin" ]; then
export HADOOP_HOME="`brew --prefix hadoop`"
export MONO_GAC_PREFIX="/usr/local"
export BASH_SILENCE_DEPRECATION_WARNING=1
setjdk() { # Set java version on the fly
    export JAVA_HOME=$(/usr/libexec/java_home -v $1)
}
export CLICOLOR=1
export LSCOLORS=DxFxCxAxBxegedabagacad
alias ls=' ls -GFh'

# if Linux
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
    export LS_COLORS="di=1;33:ln=1;35:so=1;32:pi=1;30:ex=1;31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43"
    alias pbcopy='xsel --clipboard --input'
    alias pbpaste='xsel --clipboard --output'
    alias open='xdg-open'
    alias ls='ls --color=auto'

    # Setup keychain
    /usr/bin/keychain $HOME/.ssh/id_rsa $HOME/.ssh/id_ed25519 $HOME/.ssh/imagine_id_rsa $HOME/.ssh/nido_id_ed25519
    /usr/bin/keychain --agents gpg AE38865D
    . $HOME/.keychain/${HOSTNAME}-sh
    . $HOME/.keychain/${HOSTNAME}-sh-gpg
    # . $HOME/.keychain/${HOSTNAME}-sh-gpg # gpg keychain
    # Flush all cached keys in memory. Any agent(s) will continue to run.
    # Rationale: any user logging in should be assumed to be an intruder
    # Passphrase is needed upon login, but cron jobs (etc...) will still
    # run when logging out
    # /usr/bin/keychain --clear

fi

# if Arch Linux
if [ -f "/etc/arch-release" ]; then
    alias cower='cower -c'
    alias mc=minio-client
    alias wifi='sudo wifi-menu'
fi

source ~/.setup/.git-completion.bash
source /usr/local/arcanist/resources/shell/bash-completion
source ~/.setup/.bashrc.local

complete -C /usr/bin/vault vault
complete -C /usr/bin/aws_completer aws
complete -C /usr/bin/terraform terraform
alias please='python ~/workspace/imagine/infrastructure/scripts/please/please.py'