-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbashrc_common
231 lines (185 loc) · 6.53 KB
/
bashrc_common
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# vim:set foldmarker=#-#,#.# foldmethod=marker:
#=================================================================
# test -s ~/GIT/confs/bashrc_common && source ~/GIT/confs/bashrc_common
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
set -o notify
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# colored GCC warnings and errors
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
#export XKEYSYMDB=/usr/share/X11/XKeysymDB # xmgrace related
if [ -t 1 ]; then
bind '"\e[5~": history-search-backward'
bind '"\e[6~": history-search-forward'
fi
#bind '"\M-[3~": delete-char'
# Vi in command line
#set -o vi
#bind -m vi-insert "\C-l":clear-screen
#=================================================================
#-# Aliases
alias ll='ls -l --color=auto --group-directories-first'
alias lt='ls -lrt --color=auto'
#alias la='ls -A --color=auto'
#alias l='ls -CF --color=auto'
alias cdrp='cd $(realpath .)'
alias cdd='cd "$(ls -dt */ | head -1)"'
alias pwdm='pwd > $HOME/.pwdmark'
alias cdm='cd $(cat $HOME/.pwdmark)'
alias dirsw='dirs > $HOME/.dirsm'
alias dirsr='for i in $(dirs); do popd -n -0 2> /dev/null ; done ; for i in $(cat $HOME/.dirsm); do pushd -n ${i} > /dev/null ; done'
alias bat='batcat -P -p'
alias xc='xclip-copyfile'
alias xp='xclip-pastefile'
alias xo='xclip -o'
alias xi='xclip'
alias yd='youtube-dl -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo+bestaudio" --merge-output-format mp4'
alias bssh='ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR '
alias bscp='scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR '
alias mc='source /usr/lib/mc/mc-wrapper.sh'
alias xmgrace='xmgrace -geometry 1230x900'
alias beep='echo -en "\007"'
alias rpminfo='rpm -qivlp --scripts'
alias du='du -h --max-depth=1'
alias psp='ps -efw | grep $USER'
alias ngit='git --no-pager'
alias lupdatedb='updatedb -U $HOME -o $HOME/bin/plocate.db --prunenames external_1TB -l 0'
alias llocate='locate -d $HOME/bin/plocate.db'
alias nextflow-clean-but-last='nextflow clean -f -before $(nextflow log -q | tail -n 1)'
alias nextflow-clean-all='nextflow clean -f -before $(nextflow log -q | tail -n 1); nextflow clean -f'
alias Uppsala='curl wttr.in/Uppsala?MF'
alias google-chrome='google-chrome --save-page-as-mhtml'
#.#
#=================================================================
#=================================================================
#-# Bash functions
# Functions to help us manage paths. Second argument is the name of the
# path variable to be modified (default: PATH)
pathremove () {
local IFS=':'
local NEWPATH
local DIR
local PATHVARIABLE=${2:-PATH}
for DIR in ${!PATHVARIABLE} ; do
if [ "$DIR" != "$1" ] ; then
NEWPATH=${NEWPATH:+$NEWPATH:}$DIR
fi
done
export $PATHVARIABLE="$NEWPATH"
}
pathprepend () {
pathremove $1 $2
local PATHVARIABLE=${2:-PATH}
export $PATHVARIABLE="$1${!PATHVARIABLE:+:${!PATHVARIABLE}}"
}
pathappend () {
pathremove $1 $2
local PATHVARIABLE=${2:-PATH}
export $PATHVARIABLE="${!PATHVARIABLE:+${!PATHVARIABLE}:}$1"
}
pathclean () {
export PATH=$( python -c "import os; path = os.environ['PATH'].split(':'); print(':'.join(sorted(set(path), key=path.index)))" )
}
calc() { echo print "$@" | gnuplot; }
mkdircd(){ mkdir "$1" && cd "$1" ; }
# This function defines a 'cd' replacement function capable of keeping,
# displaying and accessing history of visited directories, up to 10 entries.
# To use it, uncomment it, source this file and try 'cd --'.
# acd_func 1.0.5, 10-nov-2004
# Petar Marinov, http:/geocities.com/h2428, this is public domain
cd_func ()
{
local x2 the_new_dir adir index
local -i cnt
if [[ $1 == "--" ]]; then
dirs -v
return 0
fi
the_new_dir=$1
[[ -z $1 ]] && the_new_dir=$HOME
if [[ ${the_new_dir:0:1} == '-' ]]; then
#
# Extract dir N from dirs
index=${the_new_dir:1}
[[ -z $index ]] && index=1
adir=$(dirs +$index)
[[ -z $adir ]] && return 1
the_new_dir=$adir
fi
#
# '~' has to be substituted by ${HOME}
[[ ${the_new_dir:0:1} == '~' ]] && the_new_dir="${HOME}${the_new_dir:1}"
#
# Now change to the new dir and add to the top of the stack
pushd "${the_new_dir}" > /dev/null
[[ $? -ne 0 ]] && return 1
the_new_dir=$(pwd)
#
# Trim down everything beyond 11th entry
popd -n +11 2>/dev/null 1>/dev/null
#
# Remove any other occurence of this dir, skipping the top of the stack
for ((cnt=1; cnt <= 10; cnt++)); do
x2=$(dirs +${cnt} 2>/dev/null)
[[ $? -ne 0 ]] && return 0
[[ ${x2:0:1} == '~' ]] && x2="${HOME}${x2:1}"
if [[ "${x2}" == "${the_new_dir}" ]]; then
popd -n +$cnt 2>/dev/null 1>/dev/null
cnt=cnt-1
fi
done
return 0
}
alias cd=cd_func
#.#
#=================================================================
#=================================================================
#-# Export section
export LESS="-I -R"
export LS_OPTIONS="-N --color=tty"
#export LC_ALL=C.UTF-8
export TZ="Europe/Stockholm"
#export LC_TIME=C.UTF-8
export LC_PAPER=en_IE.utf8
export LC_MEASUREMENT=en_IE.utf8
export EDITOR=vim
export PATH=$PATH:$HOME/bin:$HOME/.local/bin
# 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"
#PS1='\[\e]2;\h: $(ppwd)\007\e]1;\h\007\]\e[4m\h\e[0m: \W> '
#PS1="\[\e]2;\h: \w\a\e[32;4m\]\h\[\e[0m\]: \W> " latest
PS1="\[\e]2;\h: \w\a\e[32;4m\]\h\[\e[0m\]:[\w]\n[\t]> "
;;
*)
;;
esac
test -s /usr/local/etc/bash_completion.d/singularity && source /usr/local/etc/bash_completion.d/singularity
if [ ! -z $SINGULARITY_NAME ]; then
export PS1="[S] "$PS1
fi
if [ ! -z $container_uuid ]; then
export PS1="[UD] "$PS1
fi
#.#
#=================================================================
#=================================================================
#-# PATH section
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
pathappend $HOME/bin
fi
if [ -d "$HOME/.local/bin" ] ; then
pathappend $HOME/.local/bin
fi
#.#
#=================================================================