-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.aliases
106 lines (106 loc) · 3.25 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
#!/bin/bash
#alises for job control - make zsh behave like bash
disown() {
if [[ $# -eq 1 && $1 = - ]]; then
builtin disown %-
else
builtin disown %"$@"
fi
}
bg() {
if [[ $# -eq 1 && $1 = - ]]; then
builtin bg %-
else
builtin bg %"$@"
fi
}
fg() {
if [[ $# -eq 1 && $1 = - ]]; then
builtin fg %-
else
builtin fg %"$@"
fi
}
_tmux_send_keys_all_panes_ () {
for _pane in $(tmux list-panes -F '#P'); do
tmux send-keys -t ${_pane} "$@"
done
}
command_exists () {
type "$1" &> /dev/null ;
}
findListeningPort() {
#ss is better than netstat at detecting wrappers like pm2
theCmd=$(sudo ss -nlp | grep -iE "$1")
if [ $? -eq 0 ] && [ -n "$theCmd" ]; then
echo $theCmd
else
echo "Nothing listening on $1"
fi
}
tmuxattach() {
tmux attach-session -t $1
}
tmuxDefaultJoin() {
if tmux ls 2>&1 | grep -iE '(failed|no server|no current session|no session)'; then
tmux new -s aaron
else
tmux attach-session -t aaron
fi
}
sourceFiles() {
if [[ $SHELL == *"zsh"* ]]; then
source ~/.zshrc
elif [ $SHELL == "bin/bash" ]; then
source ~/.bashrc
fi
}
grepdotfilesFunc() {
# helper to find defined aliases in dotfiles excluding history
grep -RiE $1 $(find . -maxdepth 1 -type l,f | cut -d '/' -f2 | grep -E '^\.' | grep -vE '(history|zcompdump)')
}
findMacPort() {
sudo lsof -nP -iTCP:$1
}
if command_exists gls ; then
alias ls='gls --color=auto' #use ls from homebrewe install of coreutils if available
fi
alias cl="clear"
alias ll="ls -lah --color=auto"
alias lt="ls -laht --color=auto"
alias la='ls -A --color=auto'
alias l='ls -CF --color=auto'
alias lol='ll $(find . -maxdepth 1 -type l -print)'
alias sourceme=sourceFiles
alias tmux="tmux -2"
alias joinme=tmuxDefaultJoin
alias leave="tmux detach"
alias gitlog="git log --oneline --abbrev-commit --all --graph --decorate --color"
alias ssh='ssh -o ServerAliveInterval=30 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no '
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias whatip="ip addr | grep inet | grep -v inet6 | grep -Ev '\slo' | cut -d ' ' -f6 | cut -d '/' -f1"
alias dirs="ls -aldh .*/ */"
alias tmuxa=tmuxattach
alias dirs="ls -lah | grep '^d'"
alias vi="vim"
alias realjava="sudo ps aux | grep java | grep -vE '(eclipse|grep)'"
alias netrestart="sudo ifdown eth0 && sudo ifup eth0"
alias fport="findListeningPort"
alias dotfiles="find . -maxdepth 1 -type f | cut -d '/' -f2- | grep -iE '^\.' | xargs ls -lah --color=auto"
alias onlyfiles="find . -maxdepth 1 -type f | cut -d '.' -f2- | cut -c 2- | grep -vE '^\.' | xargs ls -lah --color=auto"
alias grepdotfiles=grepdotfilesFunc
alias stockdale="whoami && hostname && history | tail -n 5"
alias wats="cat package.json | jq '.scripts'"
alias watd="cat package.json | jq '.dependencies'"
alias watdd="cat package.json | jq '.devDependencies'"
alias glog="git log --date=local"
# mac specific aliases
alias grep="ggrep"
alias nrt="npm run test"
alias nru="npm run test-unit"
alias nrl="npm run lint"
alias macport=findMacPort
alias grepnm="grep -RiE --exclude-dir=node_modules"
alias greppy="grep -RiE --exclude-dir=.eggs --exclude-dir=.git --exclude-dir=build --exclude-dir=lib"