-
Notifications
You must be signed in to change notification settings - Fork 0
/
.aliases
115 lines (102 loc) · 3.35 KB
/
.aliases
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
#==============================================================================
#= Aliases =
#==============================================================================
#= development ==============================================================
alias b='bundle'
alias be='bundle exec'
alias gadd="git add -u && git add . && git status"
#= bash =====================================================================
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias ag='rg'
alias cd..='cd ..'
alias c='clear'
alias diff='colordiff'
alias e='exit'
alias g='rg'
alias grep='grep ${GREP_OPTIONS}'
alias h='history'
alias ht='HISTTIMEFORMAT="%F %T " history'
alias ls='/bin/ls -hF ${LS_OPTIONS}'
alias ls.='ls -d .*'
alias l='ls -l'
alias l.='ls -ld .*'
alias la='ls -al'
alias ll='ls -Al'
alias more='less'
#alias root="sudo bash -l"
alias ssh='ssh-sync'
#alias sudo='sudo -Es'
alias vi='vim'
alias v='code'
alias k='kinit -fl7d'
alias htop='TERM=xterm-color htop'
alias w='COLUMNS=$(tput cols) w | sed "1s/\(.*\)/\n\1 (np:$(nproc))/"'
# Pipe anything into `clip` to forward it to Clipper
alias clip="nc -q0 localhost 8377"
#==============================================================================
#= Functions =
#==============================================================================
#= Back-Up file =============================================================
#bu () { cp -a "$1" "$1"~$(date +%F.%T)~; }
bu () {
pattern='^.*[^/]' # get everything except for trailing forward-slashes
[[ $1 =~ $pattern ]] # match regex
file=${BASH_REMATCH[0]} # assign matched pattern to "$file"
cp -a "$file" "$file"~$(date +%F.%T)~
}
#= File Creation/Birth Time =================================================
dbstat () {
file=$(readlink -f ${1})
filesystem=$(df ${file} | awk 'NR == 2 {print $1}')
sudo debugfs -R "stat ${file}" ${filesystem} | cat
}
#= git clone helper =========================================================
gc () {
[[ ${1} =~ @([^/:]+)[/:](.+)/(.+)\.git ]]
parent="${HOME}/code/${BASH_REMATCH[1]}/${BASH_REMATCH[2]}"
mkdir -p ${parent}
git -C ${parent} clone ${1}
cd ${parent}/${BASH_REMATCH[3]}
}
#= PyEnv Setup ==============================================================
pyenv-setup() {
(
set -euxo pipefail
pyenv install $(cat .python-version | sed 's/[^0-9.]*//g')
pyenv virtualenv $(cat .python-version | sed 's/[^0-9.]*//g') $(cat .python-version)
)
}
#= Random Sort ==============================================================
rsort () {
if sort -R /dev/null 2> /dev/null; then
sort -R
else
while IFS= read -r f; do printf "%05d %s\n" "$RANDOM" "$f"; done | sort -n | cut -c7-
fi
}
#= tmux session helper ======================================================
tm ()
{
if [[ $# -eq 0 ]]; then
tmux ls;
else
tmux has -t $1 2> /dev/null;
if [[ $? -eq 0 ]]; then
tmux attach -dt $1;
else
tmux new-session -s $1;
fi;
fi
}
#= Create tmp dir ===========================================================
function tmp {
local parent="$HOME/tmp/scratch"
local latest="$parent/latest"
local scratch="$parent/scratch-`date +'%s'`"
mkdir -p $scratch
ln -nfs $scratch $latest
cd $latest
echo "Created $scratch"
}