-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathalias.symlink
More file actions
113 lines (93 loc) · 2.45 KB
/
alias.symlink
File metadata and controls
113 lines (93 loc) · 2.45 KB
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
alias vim='mvim -v'
alias dc='docker compose'
alias dcb='docker compose build'
alias dcup='docker compose up'
alias dcr='docker compose run --service-ports --rm'
alias dcps='docker compose ps'
alias dclogs='docker compose logs'
alias gosrc='cd $GOPATH/src'
alias grep_exclude_node_modules='grep --exclude-dir="node_modules"'
alias tm="gtime --format='\n---\n\"%C\" took %e seconds with %P CPU usage\n---\n'"
alias new_uuid='uuidgen | tr "[:upper:]" "[:lower:]"'
alias brewup='brew update; brew upgrade; brew prune; brew cleanup; brew doctor'
alias gh='github'
dcrun() {
container_name=$1
docker compose run --rm --use-aliases --service-ports $container_name sh
}
reload-alias() {
if [ -f /vagrant/alias.sh ]; then
source /vagrant/alias.sh
echo "> alias reloaded"
elif [ -f ~/Development/alias.sh ]; then
source ~/Development/alias.sh
echo "> alias reloaded"
else
echo "> alias NOT reloaded"
fi
}
dcrm(){
docker compose stop $1
docker compose rm --force $1
}
# Mac
# --------------------------
## find process by executable name and show the working directory as well
pgrep_pwdx() {
for p in $(pgrep $1); do
echo "$p | $(pwdx $p)"
done
}
## pwdx for Mac https://gist.github.com/tobym/648188
function pwdx {
lsof -a -d cwd -p $1 -n -Fn | awk '/^n/ {print substr($0,2)}'
}
## Print process current working directory
function pcwd {
lsof -a -d cwd -p $1
}
## Kill program process running in the current working directory.
kill_process_cwd (){
program=$1
if [ -z $program ]; then
echo "Missing program arg"
return 1
fi
for p in $(pgrep $1); do
p_path="$(pwdx $p)"
if [[ "$p_path" = "$(pwd)" ]]; then
echo "Exiting process $p at $p_path"
kill "$p"
return 0
fi
done
echo "Could not find process"
return 1
}
get_wifi_ip(){
ipconfig getifaddr en0
}
kill_process_running_at_port() {
if [ -z "$1" ]; then
echo "Usage: kill_process_running_at_port [numeric port identifier]" >&2
return 1
fi
pid=$(lsof -i TCP:$1 | awk '/LISTEN/{print $2}')
if [ -z "$pid" ]; then
echo "No process found on this port"
return 1
fi
kill -9 $pid
echo "Process killed"
}
## -> Load secret configurations
source ~/Dropbox/dotfiles-secret/alias.sh
envup () {
envfile=$1
set -o allexport; source $envfile; set +o allexport
}
if type rg &> /dev/null; then
export FZF_DEFAULT_COMMAND='rg --files'
export FZF_DEFAULT_OPTS='-m --height 50% --border'
# export FZF_DEFAULT_COMMAND='rg --files --no-ignore-vcs --hidden'
fi