-
Notifications
You must be signed in to change notification settings - Fork 0
/
bashrc
158 lines (140 loc) · 5.39 KB
/
bashrc
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#------------------------------------------------------------------------------
# FROM DEBIAN STD CONFIG
#------------------------------------------------------------------------------
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
fi
#------------------------------------------------------------------------------
# MISC
#------------------------------------------------------------------------------
# Set default text editor:
export EDITOR="/usr/bin/vim"
# Set LD correctly for LAMMPS
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/Users/andreasilva/phd/software/lammps/lammps-12Dec18/src"
#eval "$(_VERDI_COMPLETE=source verdi)" # Autocomplete for verdi aiiida
# Enable bash completion for git
source /usr/local/share/zsh/site-functions/git-completion.bash
#------------------------------------------------------------------------------
# SETUP HISTORY
#------------------------------------------------------------------------------
# From Tsh
# Don't put duplicate lines in the history
# Don't save commands which start with a space
HISTCONTROL=ignoredups:erasedups:ignorespace
HISTTIMEFORMAT="%Y/%m/%d %R "
HISTSIZE=10000
HISTFILESIZE=10000
shopt -s histappend # Append to the history file, don't overwrite it
shopt -s histreedit # Re-edit a failed history substitution
shopt -s histverify # Verify an history substitution before executing
#------------------------------------------------------------------------------
# DEFINE COLORS
#------------------------------------------------------------------------------
BOLD="$(tput bold)"
RESET="$(tput sgr0)"
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
YELLOW="$(tput setaf 3)"
BLUE="$(tput setaf 4)"
MAGENTA="$(tput setaf 5)"
CYAN="$(tput setaf 6)"
WHITE="$(tput setaf 7)"
#------------------------------------------------------------------------------
# DEFINE CUSTOM PROMPT
#------------------------------------------------------------------------------
# Define base colored PS1
# It should look something like "<use> in <last dir in PWD> $"
PS1='\[$BOLD\]\[$BLUE\]\u\[$WHITE\] in \[$GREEN\]\W'
# Signal bash via ssh connection at the end of PS1
if [[ -n "${SSH_CONNECTION:-}" ]]
then
PS1="$PS1"'\[$RESET\]\[$CYAN\] [ssh]'
fi
# If in git repo, put branch name in PS1
# Put '*' for unstaged changes and '+' for staged-not-commited changes
GIT_PS1_SHOWDIRTYSTATE=true
export PS1="$PS1"'\[$RESET\]\[$CYAN\]$(__git_ps1 " [%s]")'
# Reset color at the end of PS1
PS1="$PS1"' \[$RESET\]$ '
#------------------------------------------------------------------------------
# PYTHON CONFIG
#------------------------------------------------------------------------------
# Execute Python start up script to set up config
export PYTHONSTARTUP="$HOME/.pythonrc"
export PYTHONPATH="$PYTHONPATH:$HOME/bin/"
#------------------------------------------------------------------------------
# ALIASES
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# DEFINE PATH
#------------------------------------------------------------------------------
# User executables and modules
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
#------------------------------------------------------------------------------
# SOURCE OTHER CONFIG FILES
#------------------------------------------------------------------------------
# List of aliases
if [ -f "$HOME/.bash_aliases" ] ; then
source "$HOME/.bash_aliases"
fi
# Handy functions too long to be in this file
if [ -f "$HOME/.bash_functions" ] ; then
source "$HOME/.bash_functions"
fi
# Machine-specific config
if [ -f "$HOME/.bash_machine" ] ; then
source "$HOME/.bash_machine"
fi
# I forgo the computer unlocked while having a coffe with Paolo.
# Victor, rightfully, took advantage of the situation.
# This is a reminder of your careless behaviour! A. 13.09.19
figlet PINEAPPLE PIZZA
# Start ssh-agent
# Check if the ssh-agent is already running
if [[ "$(ps -u $USER | grep ssh-agent | wc -l)" -lt "2" ]]; then
echo "$(date +%F@%T) - SSH-AGENT: Agent will be started"
# Start the ssh-agent and redirect the environment variables into a file
ssh-agent -s > $HOME/.ssh/ssh-agent
# Load the environment variables from the file
. ~/.ssh/ssh-agent >/dev/null
# Add the default key to the ssh-agent
ssh-add ~/.ssh/id_rsa_ir5
ssh-add ~/.ssh/id_rsa_marvin
ssh-add ~/.ssh/id_rsa_sissa
else
echo "$(date +%F@%T) - SSH-AGENT: Agent already running"
. ~/.ssh/ssh-agent >/dev/null
fi