-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbashrc.inc
More file actions
204 lines (180 loc) · 6.11 KB
/
bashrc.inc
File metadata and controls
204 lines (180 loc) · 6.11 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
# vim: ft=sh
# enable color support of ls and also add handy aliases
#PATH="$HOME/.local/bin:$PATH"
set -o noclobber # don't allow > to overwrite existing files
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
export LC_ALL=en_US.utf-8
export LS_COLORS="rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30:ow=34:st=37;44:ex=32;1:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;"
export EDITOR=nvim
export TF_CLI_ARGS_apply='-parallelism 24'
export TF_CLI_ARGS_plan='-parallelism 24'
export TF_CLI_ARGS_destroy='-parallelism 24'
export PSQL_PAGER="pspg -s 6"
alias xml=xmlstarlet
alias csvalign="column -t -s,"
alias pcsv="pspg -s 6 --csv -f"
alias bat=batcat
alias mysql="mysql --pager='pspg -s 6'"
alias renumber="tmux movew -r"
alias dive="sudo docker run -v /var/run/docker.sock:/var/run/docker.sock -it wagoodman/dive"
alias ll='ls -alh --file-type'
alias la='ls -a'
alias l='ls -CF'
alias ltr='ls -Alhrt --file-type'
alias s3=s5cmd
alias gl='git log'
alias gg='git graph'
alias jl='jj log'
alias reset='tput reset' # removes unnecessary delay
alias fd=fdfind
alias mm=micromamba
alias v=nvim
alias d=deactivate
alias rgg='rg --no-ignore'
alias xo=xdg-open
alias ur='uv run'
alias j=jj
alias jb='jj b'
comp() {
if [ "$1" != "" ]; then
docker compose "$@"
else
docker compose ps --format 'table {{.Service}}\t{{.Status}}\t{{.Name}}\t{{.Ports}}'
fi
}
function scd {
cd "$(tmux display-message -p '#{session_path}')"
}
brightness() {
sudo $(which set_brightness.sh) "$@"
}
contrast() {
sudo $(which set_contrast.sh) "$@"
}
function jat {
jq . "$@" | bat -l json
}
function lsd {
if [ -z "$1" ]; then
pf=""
elif [[ "$1" == */ ]]; then
pf="$1"
else
pf="$1/"
fi
ls -d "$pf".*/ "$pf"*/
}
# start fugitive in fullscreen, optionally with a git command
function fug {
if [ -z "$1" ]; then
nvim +'call GFull()'
else
nvim +":G $*" +":normal o"
fi
}
# paged pretty ripgrep
function rg {
command rg -p "$@" | less -RF
}
function keep_trying {
while ! "$@"; do sleep 1; done
}
function duh {
du -ha "$@" | sort -h
}
function ripsed {
pattern="$1"
replacement="$2"
mapfile -t files < <(command rg --files-with-matches "$pattern")
count=${#files[@]}
if [ "$count" == 0 ]; then
>&2 echo "No matches found."
else
command rg "$pattern" -r "$replacement"
>&2 echo -n "Perform above replacements on all $count files [y/n]? "
read answer
if [[ "${answer^}" =~ ^Y ]]; then
for x in "${files[@]}"; do
sed -i "s|$pattern|$replacement|g" "$x"
done
>&2 echo "Done."
else
>&2 echo "Cancelling."
fi
fi
}
function get_aws_secret {
aws secretsmanager get-secret-value --secret-id "$@" | jq -r '.SecretString'
}
gcd() {
cd "$(git rev-parse --show-toplevel 2>/dev/null || pwd)"/"$1"
}
# smart git alias:
# - just g gives git status
# - with args, passes through to git
g() {
if [ -z "$1" ]; then
git status
else
git "$@"
fi
}
# enable completion for g:
if [ -f /usr/share/bash-completion/completions/git ]; then
. /usr/share/bash-completion/completions/git
___git_complete g __git_main
fi
function privateip {
ip a show dev "${1:-eth0}" | perl -ne '/^\s*inet ([\d\.]+)\// and print $1'
}
function publicip {
curl https://checkip.amazonaws.com
}
function tmux {
if [ "$1" == "" ]; then
"$(which tmux)" new-session -A -s anthony
else
"$(which tmux)" "$@"
fi
}
function docker-rmi {
docker image ls --format '{{.Repository}}:{{.Tag}}' "$@" | xargs docker rmi
}
function ecr-delete-untagged {
local repo=$1
local region=${2-ap-southeast-2}
local images
images=$(aws ecr list-images --region "$region" --repository-name "$repo" --filter "tagStatus=UNTAGGED" --query 'imageIds[*]' --max-items 100 --output json)
if [ "$images" == "[]" ]; then
>&2 echo "No untagged images in ECR repo $repo"
else
aws ecr batch-delete-image --region "$region" --repository-name "$repo" --image-ids "$images"
fi
}
eval "$(fzf --bash)"
eval "$(starship init bash)"
source <(COMPLETE=bash jj)
function a {
for d in .venv venv env .env; do
if [ -e $d/bin/activate ]; then
. $d/bin/activate
return
fi
done
>&2 echo "Could not find a virtualenv in ./[.][v]env."
}
function s3mount {
b="$1"
p=/s3/"$b"
test -d "$p" || mkdir -p "$p"
(
eval "$(aws configure export-credentials --format env)"
s3fs -d -o use_path_request_style -o endpoint=ap-southeast-2 -o url=https://s3-ap-southeast-2.amazonaws.com "$b" "$p"
)
}