-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_bashrc.alias
More file actions
executable file
·222 lines (181 loc) · 5.7 KB
/
Copy path_bashrc.alias
File metadata and controls
executable file
·222 lines (181 loc) · 5.7 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
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
#!/usr/bin/env bash
##################################################
# Custom completion_functions
##################################################
function _compopt_o_filenames
{
# This isn't on ubuntu
type compopt &>/dev/null && compopt -o filenames 2>/dev/null || \
compgen -f /non-existing-dir/ >/dev/null
}
function custom_cd_alias
{
local alias_name="$1"
local alias_dir="$2"
if [ ! -d "${alias_dir}" ]
then
# echo "ERROR: Alias Dir [$alias_dir] not found for $alias_name, skipping"
return
fi
local completionFunction=$(cat <<EOT
# Generate a new completion function name
function _$alias_name() {
local cur IFS=\$'\n' j k
_get_comp_words_by_ref cur
k=0
_compopt_o_filenames
for j in \$( compgen -d "$alias_dir/\$cur" )
do
dbgComplete "$j"
j="\${j}/"
COMPREPLY[k++]=\${j#$alias_dir/}
done
if [[ \${#COMPREPLY[@]} -eq 1 ]]; then
i=\${COMPREPLY[0]}
if [[ "\$i" == "\$cur" && \$i != "*/" ]]; then
COMPREPLY[0]="\${i}/"
fi
fi
return 0
};
EOT
);
eval "$completionFunction"
local aliasFunction=$(cat <<EOT
# Generate a new completion function name
function $alias_name() {
cd "$alias_dir/\$@"
};
EOT
);
eval "$aliasFunction"
# Register the alias completion function
complete -F _$alias_name -o nospace $alias_name
}
custom_cd_alias cg $GIT_ROOT
custom_cd_alias cgp $GIT_ROOT/grandelatte/_pages
custom_cd_alias cgd $GIT_ROOT/ha-dashboard/dashboards
custom_cd_alias cgm $GIT_ROOT/mostlymonoastro
custom_cd_alias cga $GIT_ROOT/astrophotography
custom_cd_alias ce $UNIX_ENV_DIR
custom_cd_alias ca $ASTRO_IMAGE_ROOT
function docker_alias_completion_wrapper
{
local completion_function="$1";
local alias_name="$2";
local func=$(cat <<EOT
# Generate a new completion function name
function _$alias_name() {
# Start off like _docker()
local previous_extglob_setting=\$(shopt -p extglob);
shopt -s extglob;
# Populate \$cur, \$prev, \$words, \$cword
_get_comp_words_by_ref -n : cur prev words cword;
# Declare and execute
declare -F $completion_function >/dev/null && $completion_function;
eval "\$previous_extglob_setting";
return 0;
};
EOT
);
eval "$func";
# Register the alias completion function
complete -F _$alias_name $alias_name
}
function dbgComplete
{
echo $* >> /tmp/comp
}
function bulkDbgComplete
{
rep=$
dbgComplete "$* cur [$cur]"
dbgComplete "$* COMP_CWORD [$COMP_CWORD]"
dbgComplete "$* COMP_LINE [$COMP_LINE]"
dbgComplete "$* COMP_POINT [$COMP_POINT]"
dbgComplete "$* COMP_WORDBREAKS [$COMP_WORDBREAKS]"
dbgComplete "$* COMP_WORDS [$COMP_WORDS]"
dbgComplete "$* COMPREPLY [$(echo ${COMPREPLY[@]} | tr ' ' '\n'| head -5)]"
dbgComplete ""
}
alias new=newf
alias h="history 1000"
alias j="jobs -l"
alias pd="pushd"
alias po="popd"
alias d="dirs -l"
alias md="mkdir"
alias rd="rm -r"
alias p="more -c"
alias me="ps -fu $USER"
alias clean="rm -f *~ .*~"
alias ups="usr/ucb/ps -aguxww"
alias ugrep="usr/ucb/ps -aguxww| grep $USER |grep "
function hgrep
{
history 1000 | grep "$*"
}
alias nsl="netstat -na | grep -w LISTEN| sort"
alias xe="chmod +x"
alias emx="emacs -nw"
alias ww="chmod +w"
alias cdd="cd ~/Downloads"
alias cd.="cd .."
alias cd..="cd .."
alias cd...="cd ../.."
alias cd....="cd ../../.."
alias cd.....="cd ../../../.."
# Standard LS aliases
#
alias ls="ls -F"
alias l="ls -lh"
alias la="ls -la"
alias ll="ls -lhA"
alias l1="ls -1"
alias tg="treegrep"
alias gg="treegrep -x go"
alias pbj="pbpaste | jq . --sort-keys"
alias sha256="shasum -a 256"
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]
then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto -F'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# Some tail -f aliases (Tailiases?)
alias tf="tail -f"
alias dtl="docker logs --tail 30 --follow"
docker_alias_completion_wrapper __docker_complete_containers_all dtl
function deb { docker exec -it $@ bash ;}
docker_alias_completion_wrapper __docker_complete_containers_running deb
function desh { docker exec -it $@ sh ;}
docker_alias_completion_wrapper __docker_complete_containers_running desh
function debb { docker run -it --rm busybox sh ;}
alias tunnels="ssh -f -N gcptunnel"
alias gcptunnel="ssh -f -N gcptunnel"
alias emasc=emacs
alias be="bundle exec"
alias topb="top -l 99 -n 20 -o cpu -ncols 17"
# alias fixcanvas="pbpaste | sed $'s@|@\\\n|@g'|pbcopy ; pbpaste"
alias gs="git status"
alias gc="git clone"
alias dps="docker ps --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}' -a | (read -r header && echo \"\$header\" && sort -k1,1)"
alias dil="docker image ls"
alias dcd="docker compose down --remove-orphans"
alias dcu="docker compose up --detach --force-recreate --remove-orphans"
alias dcdu="docker-compose down && docker-compose up --detach"
alias p8="ping 8.8.8.8"
alias p5="ping 192.168.1.5"
alias p1="ping 192.168.1.1"
alias pk="ping 192.168.1.80"
alias cqg=createQuickGIF.sh
alias cgq=createQuickGIF.sh
alias iap="importAstroPhotos.sh -d"