-
Notifications
You must be signed in to change notification settings - Fork 9
/
aliases_shared
132 lines (110 loc) · 3.21 KB
/
aliases_shared
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
alias cd.="cd .."
alias cd2.="cd ../.."
alias cd3.="cd ../../.."
alias cd4.="cd ../../../.."
alias cd5.="cd ../../../../.."
alias cd6.="cd ../../../../../.."
alias ll='ls -halF'
alias la='ls -A'
alias l='ls -CF'
alias python="python3"
alias pip="pip3"
if [ -s /usr/bin/vim ]; then
alias vi="/usr/bin/vim"
fi
if type "nvim" > /dev/null; then
alias vim="nvim"
fi
# System shortcuts
mkcd() {
command mkdir $1 && cd $1
}
cdl() {
cd "$@" && ls;
}
function clearswap() {
rm ~/.local/share/nvim/swap/*swp
}
alias clearswap='clearswap'
# tmux shortcuts
function tmux_public() {
if [ -n "$TMUX" ]; then
tmux_filepath=${TMUX%%,*}
chmod 777 $tmux_filepath
else
echo "You must run this command from within a tmux session"
fi
}
function tmux_secure() {
if [ -n "$1" ]; then
chmod 700 /tmp/$1
echo "Set session to be private ($1)"
else
echo "Please specify the name of a tmux to secure"
fi
}
function tmux_start () {
if [ -n "$1" ]; then
tmux -S /tmp/$1 new-session -s $1 -d
tmux_secure $1
tmux -S /tmp/$1 attach -t $1
# After detaching/exiting from the tmux
# Check if the session is still active to decide whether to clean or secure
if ps -o ruser,command -ax | grep -q "[n]ew-session -s $1" ; then
tmux_secure $1
else
rm /tmp/$1
echo "Deleted unused session ($1)"
fi
else
echo "Please specify the name of a tmux to start"
fi
}
function tmux_list () {
ps -o ruser,command -ax | grep '[n]ew-session -s' | ruby -ne '$_ =~ /^(\w+).*-s (\w+)/; puts "#{$1} started #{$2}"'
}
alias tmux-start='tmux_start'
alias tmuxs='tmux_start'
alias tmux-list='tmux_list'
alias tmuxl='tmux_list'
alias tmux-public='tmux_public'
alias tmuxpub='tmux_public'
alias pair="tmuxs pair"
# ruby shortcuts
alias bi="bundle install"
alias be="bundle exec"
alias bejs="unset RUBYOPT && bundle exec jekyll serve"
alias bems="unset RUBYOPT && bundle exec middleman server"
# alias bers="RUBYOPT='-W:no-deprecated -W:no-experimental' bundle exec rails server"
# alias berc="RUBYOPT='-W:no-deprecated -W:no-experimental' bundle exec rails console"
alias bers="bundle exec rails server"
alias berc="bundle exec rails console"
alias brake="bundle exec rake"
alias js="bundle exec jekyll serve"
# rails shortcuts
alias h="heroku run"
alias r="bin/rails"
alias rubo="bin/rubocop"
alias rgc="rg --glob='!*_test.rb' --glob='!*_spec.rb' --glob='!*.rbi' --glob='!*.json' --glob='!*test.tsx' --glob='!*test.jsx' --glob='!*.graphql'"
alias rgt="rg --glob='*test.rsx' --glob='*test.jsx' --glob='*_test.rb' --glob='*_spec.rb'"
alias unbind="rgc -l \"^\s*binding.pry\"| xargs sed -i '' -e 's/binding\.pry/# binding.pry/'"
alias rebind="rgc -l \"# binding.pry\" | xargs sed -i '' -e 's/# binding\.pry/binding.pry/'"
alias uncomment="rgc -l \"# dewyze\" | xargs sed -i '' -e '/# dewyze/d'"
# git shortcuts
alias gg="git grep"
alias g="git"
alias gt="git status"
alias gr="git reset"
alias gd="git diff"
alias gp="git push"
alias gs="git staged"
# npm shortcuts
alias nbuild="npm run build"
alias ndev="npm run dev"
alias nformat="npm run format"
alias nlint="npm run lint"
alias nlocal="npm run local"
alias nrepl="npm run repl"
alias nstart="npm run start"
alias nstory="npm run storybook"
alias ntest="npm test"