-
Notifications
You must be signed in to change notification settings - Fork 1
/
bashrc
139 lines (108 loc) · 3.46 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
# .bashrc
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# Source global definitions
[ -f /etc/bashrc ] && source /etc/bashrc
[ -f /etc/bash.bashrc ] && source /etc/bash.bashrc
# better completion
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
# completion for sudo
if [ "$PS1" ]; then
complete -cf sudo
fi
# no longer necessary to hit the <Tab> key twice to produce completions
set show-all-if-ambiguous on
set completion-ignore-case On
#-------------------------------------
# HISTORY
#-------------------------------------
# ignoredups: don't put duplicate lines in the history
# ignorespace: ignore line starting with a space
# ignoreboth: ignorespace + ignoredups
# erasedups: remove previous lines matching the current line
export HISTCONTROL=ignoreboth:erasedups
# lignes de l'historique par session bash
export HISTSIZE=50000
# lignes de l'historique conservées
export HISTFILESIZE=20000
# exclure des commandes de votre historique
#export HISTIGNORE="&:ls:cd:ll:la:ping:exit"
# append to the history file, don't overwrite it
shopt -s histappend
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
#-------------------------------------
# TERMINAL
#-------------------------------------
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# prompt
#PS1="[\u@\h: \w]$ "
# PS1="\[\e[01;32m\]\u@\h\[\e[00m\]:\[\e[01;34m\][\w]\[\e[00m\]\$ "
PS1="\[\e[01;32m\]\h\[\e[00m\]:\[\e[01;34m\]\w\[\e[00m\]\$ "
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
# Correction automatique des petites typos
shopt -s cdspell
shopt -s globstar
shopt -s autocd
#-------------------------------------
# PATH & ENV
#-------------------------------------
EDITOR=vim
#VISUAL="gvim -f"
#ALTERNATE_EDITOR=emacs
PAGER=less
PATH=$HOME/bin:$PATH
PATH=$HOME/.local/bin:$PATH
# BROWSER='firefox -new-tab'
export EDITOR VISUAL PAGER PATH ALTERNATE_EDITOR
# turn off .lesshst file
export LESSHISTFILE="-"
#-------------------------------------
# Alias definitions.
#-------------------------------------
alias ..='cd ..'
alias ...='cd ../..'
if [ -f ~/.aliases ]; then
. ~/.aliases
fi
#-------------------------------------
# Useful commands
#-------------------------------------
if [ -n "$TMUX" ]; then
function refresh {
export $(tmux show-environment | grep "^SSH_AUTH_SOCK")
export $(tmux show-environment | grep "^DISPLAY")
}
else
function refresh { :; }
fi
# run multiple Firefox
#export MOZ_NO_REMOTE=1
# calc
calc(){ awk "BEGIN{ print $* }" ;}
# slurm
shist () {
sacct --format="User,JobID,JobName%30,Partition,Account,NCpus,ReqMem,MaxVmSize,MaxRSS,state,Elapsed,start,nodelist" --units G -u $USER --start ${1:-today}
}
# Set host-specific config
[[ -f ~/.bashrc.$HOSTNAME ]] && . ~/.bashrc.$HOSTNAME
[[ -f ~/.bashrc.local ]] && . ~/.bashrc.local
# Set up fzf key bindings and fuzzy completion
eval "$(fzf --bash)"