-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.shrc
134 lines (111 loc) · 2.89 KB
/
.shrc
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
#!/bin/sh
GPG_TTY="$(tty)" && export GPG_TTY || unset GPG_TTY
# Disable the XON/XOFF feature
# https://unix.stackexchange.com/a/73499/222786
stty -ixon
# Disable blinking cursor if running in Windows Terminal
[ -n "$WT_SESSION" ] && printf '\e[2 q'
if [ -z "$EDITOR" ]
then
case "$TERM" in
xterm*|screen*|linux)
export EDITOR="$(command -v nvim 2>&1 >/dev/null && echo nvim || echo vim)"
;;
esac
fi
if [ -z "$CLICOLOR" ]
then
case "$TERM" in
xterm-*color|screen-*color|tmux-*color|xterm-ghostty)
export CLICOLOR=1
;;
esac
fi
# Environment variables
export LESS='-FR5 --mouse'
# Misc aliases
alias la='ls -lhA'
alias ll='ls -lh'
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias tree="tree -I '.git|.hg|.svn'"
command -v batcat >/dev/null && alias bat=batcat
# Neovim aliases
alias nvimconfig="nvim -c 'edit \$MYVIMRC'"
alias nvimsync='nvim --headless "+Lazy! sync" +qa'
# Shell aliases
alias shconfig='"$EDITOR" "$HOME"/.shrc'
alias bashconfig='"$EDITOR" "$HOME"/.bashrc'
alias zshconfig='"$EDITOR" "$HOME"/.zshrc'
# Git aliases
alias dot='git --git-dir="$HOME/.dotfiles.git" --work-tree="$HOME"'
alias gitconfig='git config --global -e'
# Tmux aliases
alias t=tmux
alias tt='tmux new -As "$(basename "$PWD" | LC_ALL=C.UTF-8 tr A-Z a-z)"'
alias ttd='tmux new -d -s'
alias tmuxconfig='"$EDITOR" "$XDG_CONFIG_HOME"/tmux/tmux.conf'
# Python aliases
alias activate-venv='. ./.venv/bin/activate'
alias create-venv='python3 -m venv ./.venv'
# Podman aliases
alias pcu='podman compose up'
alias pcd='podman compose down'
# Podman dev containers
dnode() {
podman run -it --rm --init \
-e NPM_CONFIG_UPDATE_NOTIFIER=false \
"$@" \
node:18 \
bash
}
# Functions
lab() {
ssh -i ~/.ssh/desotech -p 22010 student@"$1"
}
source_aws_credentials_from_csv() {
if [ "$#" -lt 1 ]
then
echo fatal: no CSV file provided >&2
else
eval "$(awk -F, 'FNR==2 { printf "export AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s", $3, $4 }' "$1")"
fi
}
renumber() {
new_number="$(printf '%02d' "$2")"
file_wo_number="${1#*.}"
if [ "$1" != "$file_wo_number" ]
then
mv -v -- "$1" "$new_number"."$file_wo_number"
fi
}
get_pwd_lowercase() {
basename "$PWD" | LC_ALL=C tr '[:upper:]' '[:lower:]'
}
stop_dscourse_dev_server() {
name="$(get_pwd_lowercase)"
for container in $(podman container ls --format '{{.Names}}')
do
if [ "$name" = "$container" ]
then
podman container stop "$name" >/dev/null
podman container rm "$name" >/dev/null
fi
done
}
start_dscourse_dev_server() {
stop_dscourse_dev_server
container_id="$(podman container run -q --detach \
--restart unless-stopped \
--init \
-v "$PWD":/mkdocs/docs:ro \
-p 127.0.0.1:"${1:-0}":80 \
--name "$name" \
r.deso.tech/desotech/dsdev)" &&
echo "http://$(podman container port "$container_id" 80)"
}
kns() {
kubectl create ns --dry-run=client -o yaml "$1" |
kubectl apply -f - &&
kubectl config set-context --current --namespace "$1"
}