-
Notifications
You must be signed in to change notification settings - Fork 0
/
.aliases
198 lines (158 loc) · 7.81 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#!/bin/bash
alias vi='nvim'
alias vim='nvim'
alias view='nvim -R'
# lsd
alias ls="lsd --group-dirs=first"
alias ll="ls -alh"
alias tree="lsd --tree"
# pretty print with syntax highlighting
alias c='pygmentize -O style=monokai,bg=dark -f console256 -g'
# list what apps are listening on what ports
alias applisten="lsof -P -i -n"
# use vim for less
alias vless="/opt/local/share/vim/vim74/macros/less.sh"
# Enable aliases to be sudo’ed
alias sudo='sudo '
# pretty print json
alias json='python -m json.tool'
# trim new lines and copy to clipboard
alias t="tr -d '\n' | pbcopy"
# Lock the screen (when going afk)
alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"
# Stopwatch
alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date'
# IP addresses
alias pubip="dig +short myip.opendns.com @resolver1.opendns.com"
alias localip="sudo ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'"
alias ips="sudo ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'"
# Flush Directory Service cache
alias flush="dscacheutil -flushcache && killall -HUP mDNSResponder"
# View HTTP traffic
alias sniff="sudo ngrep -d 'en1' -t '^(GET|POST) ' 'tcp and port 80'"
alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E \"Host\: .*|GET \/.*\""
# URL-encode strings
alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1]);"'
# Kill all the tabs in Chrome to free up memory
# [C] explained: http://www.commandlinefu.com/commands/view/402/exclude-grep-from-your-grepped-output-of-ps-alias-included-in-description
alias chromekill="ps ux | grep '[C]hrome Helper --type=renderer' | grep -v extension-process | tr -s ' ' | cut -d ' ' -f2 | xargs kill"
# Pipe my public key to my clipboard.
alias pubkey="more ~/.ssh/id_ns_rsa.pub | xclip -selection clipboard | echo '=> Public key copied to pasteboard.'"
# Pipe my private key to my clipboard.
alias prikey="more ~/.ssh/id_ns_rsa | xclip -selection clipboard | echo '=> Private key copied to pasteboard.'"
# make mkdir create path of dirs by default
alias mkdir="mkdir -pv"
# search history with grep more easily
alias histgrep="history | grep"
# find out my public ip address
alias whatsmyip="curl http://ipecho.net/plain; echo"
# configure directory stack listing
alias dirs="dirs -vl"
# start a simple http server in current folder
alias server_here="python -m SimpleHTTPServer 8000"
# find all files in current dir/and subdirs modified in the last day
alias recently_modified="find . -type f -mtime -1 -not -path './.git/*'"
alias prependtext="pbpaste | sed -e 's/^/ /' | pbcopy"
# aliases for quickly setting theme/badges for my local environment
alias t_reset="/usr/local/bin/switch-iterm-theme"
alias t_remote_mongo="/usr/local/bin/switch-iterm-theme -t=Danger -b=mongo"
alias t_local_vagrant="/usr/local/bin/switch-iterm-theme -t=Vagrant -b=vagrant"
# use fzf with highlight to preview files in command line
alias fp="fzf --preview '(highlight -O xterm256 --style=neon -l {})' --bind ctrl-j:preview-page-down,ctrl-k:preview-page-up"
alias fpp="fzf --preview '(highlight -O ansi --style=neon -l {} || head -n 100)'"
# quickly jump back up to the top of your git project
alias gcd='cd "$(git rev-parse --show-toplevel)"'
# generate phpctags for the current directory and its subdirs
# the function takes 2 args, the first is the name of the file the tags should be stored in
# the second is the directory to exclude
# todo: improve the way the function args list works for now its enough
createtags() {
echo "Running: phpctags --memory=536870912 --exclude=$2 -f $1 -R"
phpctags --memory=536870912 --exclude=$2 -f $1 -R
}
alias phptags=createtags
alias dc='docker-compose'
alias dcb='docker-compose -f docker-compose-build.yml'
alias dockerStopAll="docker stop \$(docker ps -a -q)";
alias dockerRmAll="docker rm \$(docker ps -a -q)";
alias dockerRmVolumes="docker volume rm \`docker volume ls -q -f dangling=true\`"
alias dockerRmDanglingImages="docker rmi \$(docker images -aq --filter dangling=true)"
alias dockerCleanUp="dockerStopAll; dockerRmAll; dockerRmVolumes; dockerRmDanglingImages; docker network prune"
alias dce='docker-compose -f docker-compose-experiment.yml'
alias tf-lint="docker run --rm -v \$(pwd):/data -t wata727/tflint --disable-rule=aws_elasticache_cluster_invalid_type --disable-rule=aws_elasticache_cluster_default_parameter_group"
clearDockerLog(){
dockerLogFile=$(docker inspect $1 | grep -G '\"LogPath\": \"*\"' | sed -e 's/.*\"LogPath\": \"//g' | sed -e 's/\",//g')
echo $dockerLogFile
rmCommand="rm $dockerLogFile"
screen -d -m -S dockerlogdelete ~/Library/Containers/com.docker.docker/Data/vms/0/tty
screen -S dockerlogdelete -p 0 -X stuff $"$rmCommand"
screen -S dockerlogdelete -p 0 -X stuff $'\n'
screen -S dockerlogdelete -X quit
}
alias development="pushd /Users/nadeemshabir/Development/talis && clear && ll"
alias dotfiles="pushd /Users/nadeemshabir/Development/github/dotfiles && clear && ll"
alias kibana_staging='open https://logs-eks-staging-eu.talisaspire.com/_plugin/kibana/app/discover'
alias kibana_production_eu='open https://logs-eks-eu.talisaspire.com/_plugin/kibana/app/discover'
alias kibana_production_ca='open https://logs-eks.ca.talisaspire.com/_plugin/kibana/app/discover'
alias grafana_staging='open http://grafana-eks-staging-eu.talisaspire.com/'
alias grafana_production_eu='open http://grafana-eks-eu.talisaspire.com/'
alias grafana_production_ca='open http://grafana-eks.ca.talisaspire.com/'
alias k8sdashboard_staging='open https://dashboard-eks-staging-eu.talisaspire.com/'
alias k8sdashboard_production_eu='open https://dashboard-eks-eu.talisaspire.com/'
alias k8sdashboard_production_ca='open https://dashboard-eks-ca.talisaspire.com/'
# uses aws cli to lookup instances based on a filter on the Name tag
# $1 is the profile to use
# $2 is the filter to use
# $3 is the output format defaults to 'table'
# $4 is optional, the value doesn't matter but if passed in will result
# in this function printing out the raw command its about to run
# for debugging purposes
awslookup_old() {
cmd="aws --profile $1 ec2 describe-instances --filters \"Name=tag:Name,Values=$2\" --query 'Reservations[].Instances[].[InstanceId,PublicDnsName,PrivateIpAddress,State.Name,InstanceType,join(\`,\`,Tags[?Key==\`Name\`].Value)]' --output ${3:-table}"
if [ $# -eq 4 ]
then
echo "Running $cmd"
fi
eval $cmd
}
rename() {
for i in $1*
do
mv "$i" "${i/$1/$2}"
done
}
resume_all_vms() {
for vm in $(vagrant global-status | grep saved | awk ' { print $5 } '); do
cd $vm >/dev/null
echo "Resuming: " $vm
vagrant resume
cd - > /dev/null
done
}
suspend_all_vms() {
for vm in $(vagrant global-status | grep running | awk ' { print $5 } '); do
cd $vm >/dev/null
echo "Suspending: " $vm
vagrant suspend
cd - > /dev/null
done
}
random_string() {
cmd="openssl rand -base64 $1"
eval $cmd
}
fgc() {
result=$(git branch -a --color=always | grep -v '/HEAD\s' | sort | fzf --height 90% --border --ansi --tac --preview-window right:70% --preview 'git log --oneline --graph --date=short --pretty="format:%C(auto)%cd %h%d %s" $(sed s/^..// <<< {} | cut -d" " -f1) | head -'$LINES | sed 's/^..//' | cut -d' ' -f1)
if [[ $result != "" ]]; then
if [[ $result == remotes/* ]]; then
git checkout --track $(echo $result | sed 's#remotes/##')
else
git checkout "$result"
fi
fi
}
fgs() {
git -c color.status=always status --short | fzf --height 90% --reverse --border --ansi --multi --ansi --nth 2..,.. --preview '(git diff --color=always -- {-1} | sed 1,4d; cat {-1})' --preview-window=right:70% | cut -c4- | sed 's/.* -> //'
}
export JQ_BIN_PATH='/opt/local/bin/jq'
export YQ_BIN_PATH='/Users/nadeemshabir/go/bin/yq'