-
Notifications
You must be signed in to change notification settings - Fork 1
/
.bashrc
39 lines (37 loc) · 1.23 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
## If in tty download latest rc files and load
if [ -t 1 ]; then
wget --quiet -T 2 https://raw.githubusercontent.com/inferont/shell-scripts/master/.bashrc -O ~/.bashrc_new
wget --quiet -T 2 https://raw.githubusercontent.com/inferont/shell-scripts/master/.commonrc -O ~/.commonrc_new
if [ $(stat --printf="%s" ~/.bashrc_new) -gt 200 ]; then
rm ~/.bashrc
mv ~/.bashrc_new ~/.bashrc
fi
if [ $(stat --printf="%s" ~/.commonrc_new) -gt 200 ]; then
rm ~/.commonrc
mv ~/.commonrc_new ~/.commonrc
fi
source ~/.commonrc
fi
if [ ! -f ~/bin/sshrc ]; then
wget --quiet https://raw.githubusercontent.com/inferont/sshrc/master/sshrc -O ~/bin/sshrc
chmod +x ~/bin/sshrc
ln -s ~/.commonrc ~/.sshrc
fi
alias ssh="sshrc"
alias sssh="/usr/bin/ssh"
mkdir -p ~/lib
export LD_LIBRARY_PATH=~/lib
KEEP=100
BASH_HIST=~/.bash_history
BACKUP=~/logs/bash_history/$(date +%y%m)
mkdir -p ~/logs/bash_history
HISTTIMEFORMAT="%F %s "
if [ -s "$BASH_HIST" -a "$BASH_HIST" -nt "$BACKUP" ]; then
# history file is newer then backup
if ! [[ -f $BACKUP ]]; then
# create new backup, leave last few commands and reinitialize
mv -f $BASH_HIST $BACKUP
tail -n$KEEP $BACKUP > $BASH_HIST
history -r
fi
fi