main dots / config / .bashrc-kwangya
xxwhirlpool  ·  2026-08-08
  1#!/bin/bash
  2
  3######################################
  4# default stuff i'm scared to change
  5######################################
  6
  7# If not running interactively, don't do anything
  8case $- in
  9    *i*) ;;
 10      *) return;;
 11esac
 12
 13# don't put duplicate lines or lines starting with space in the history.
 14HISTCONTROL=ignoreboth
 15
 16# append to the history file, don't overwrite it
 17shopt -s histappend
 18
 19# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
 20HISTSIZE=1000
 21HISTFILESIZE=2000
 22
 23# check the window size after each command and, if necessary,
 24# update the values of LINES and COLUMNS.
 25shopt -s checkwinsize
 26
 27# make less more friendly for non-text input files, see lesspipe(1)
 28[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
 29
 30# set variable identifying the chroot you work in (used in the prompt below)
 31if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
 32    debian_chroot=$(cat /etc/debian_chroot)
 33fi
 34
 35case "$TERM" in
 36    xterm-color|*-256color) color_prompt=yes;;
 37esac
 38
 39#force_color_prompt=yes
 40
 41if [ -n "$force_color_prompt" ]; then
 42    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
 43	color_prompt=yes
 44    else
 45	color_prompt=
 46    fi
 47fi
 48
 49if [ "$color_prompt" = yes ]; then
 50    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
 51else
 52    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
 53fi
 54unset color_prompt force_color_prompt
 55
 56# If this is an xterm set the title to user@host:dir
 57case "$TERM" in
 58xterm*|rxvt*)
 59    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
 60    ;;
 61*)
 62    ;;
 63esac
 64
 65# enable color support of ls and also add handy aliases
 66if [ -x /usr/bin/dircolors ]; then
 67    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
 68    alias ls='ls --color=auto'
 69    alias grep='grep --color=auto'
 70fi
 71
 72# enable programmable completion features
 73if ! shopt -oq posix; then
 74  if [ -f /usr/share/bash-completion/bash_completion ]; then
 75    . /usr/share/bash-completion/bash_completion
 76  elif [ -f /etc/bash_completion ]; then
 77    . /etc/bash_completion
 78  fi
 79fi
 80
 81######################################
 82# aliases
 83######################################
 84
 85# general/misc
 86alias fd="fdfind"
 87alias neofetch="hyfetch"
 88alias fastfetch="hyfetch"
 89alias bat="batcat"
 90alias cat="bat --paging=never"
 91alias iconsubfol="find . -mindepth 2 -type f -print -exec mv {} . \;"
 92alias rced="micro ~/.bashrc && source ~/.bashrc"
 93alias icat="kitty +kitten icat"
 94alias ps="ps auxww"
 95alias dd="ask dd"
 96alias freeze="freeze -c user"
 97alias glow="glow -p"
 98alias qrcode="qrencode -t ansiutf8"
 99alias ffmpeg="ffmpeg -hide_banner"
100alias open="xdg-open"
101alias c="clear"
102alias unfuckwifi="sudo systemctl restart NetworkManager"
103alias uptime="uptime -p"
104alias irc="senpai"
105alias xmpp="profanity"
106alias email="neomutt"
107alias updupgr="sudo apt update && sudo apt upgrade"
108alias winek="wineserver -k"
109alias docker="sudo docker"
110
111# weather stuff
112alias wttr="curl https://wttr.in/nyc?F0ASu"
113alias weather="wttr"
114alias wttrlg="curl https://wttr.in/nyc?F1uq"
115alias weatherlg="wttrlg"
116alias sun="daylight --short --timezone='America/New_York' | lolcat"
117
118# git
119alias gitall="git remote | xargs -L1 git push --all"
120alias gyolo="git add . && git commit -m 'yolo'"
121alias gitd="git diff --staged"
122alias gdiff="gitd"
123alias gits="git status"
124alias gita="git add ."
125alias gitlc="git diff HEAD~"
126
127# dev
128alias irb="rv run irb"
129alias ipy="python3 -i"
130
131# vpn split tunnel aliases based on a small script @ ~/.local/bin/mvpn
132alias mftp="mvpn filezilla"
133alias mterm="mvpn kitty"
134
135# cd bookmarks
136alias dotf="cd /home/kat/dotfiles"
137alias gmine="cd /home/kat/Projects/mine"
138alias scr="cd /home/kat/Scripts"
139
140# servers
141alias kssh="kitty +kitten ssh" # fujo, fujoat, goldstar, ncc1701
142
143######################################
144# variables
145######################################
146
147export EDITOR=/usr/local/bin/micro
148export "MICRO_TRUECOLOR=1"
149 
150# catppuccin colors for fzf
151export FZF_DEFAULT_OPTS=" \
152--color=spinner:#F2D5CF,hl:#E78284 \
153--color=fg:#C6D0F5,header:#E78284,info:#CA9EE6,pointer:#F2D5CF \
154--color=marker:#BABBF1,fg+:#C6D0F5,prompt:#CA9EE6,hl+:#E78284 \
155--color=border:#414559,label:#C6D0F5"
156
157# Created by `pipx` on 2025-08-05 03:36:48
158export PATH="$PATH:/home/kat/dotfiles/config/.local/bin"
159export PATH=$PATH:/usr/local/go/bin
160
161export NVM_DIR="$HOME/.config/nvm"
162[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
163[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
164
165. "$HOME/.cargo/env"
166
167. "/home/kat/.deno/env"
168
169export GOPATH="/home/kat/.godir"
170
171export GNUPGHOME="/home/kat/.config/gnupg"
172
173export ADDRBOOK_PATH="$HOME/.local/addrbook"
174export PATH="$PATH:$HOME/.local/addrbook"
175
176######################################
177# functions
178######################################
179
180cdmess() {
181	# from this blog post:
182	# https://blog.larah.me/mess-directory/
183    today_tmpdir="${TMPDIR-/tmp}/${USER}_mess/$(date +%F)"
184    mkdir -p "$today_tmpdir"
185    cd "$(mktemp -d -p "${today_tmpdir}" XXXX)" || exit 1
186}
187 
188# get a random free port. this is useful for my
189# insane sysadmin website woman adventures
190portfree() {
191	while
192		port=$(shuf -n 1 -i 1024-65535)
193		netstat -atun | grep -q "$port"
194	do
195		continue
196	done
197	echo "$port"
198}
199 
200# print internal & external IPs
201whatip() {
202	# internal
203	echo -n "internal IP: " | lolcat -p 0.7
204	hostname -I | awk '{print $1}'
205
206	# external
207	echo -n "external IP: " | lolcat -p 0.7
208	curl -4 icanhazip.com
209}
210 
211# password generator. takes input for password length by number
212passgen() {
213	PASSLENGTH=$(gum input --placeholder "type a number")
214	date +%s | sha256sum | base64 | head -c "$PASSLENGTH"; echo
215}
216
217# display random ASCII art from
218# custom dir of art in dotfiles
219# using arttime (github: poetaman/arttime)
220playart() {
221	ARTDIR="/home/kat/dotfiles/config/.local/share/arttime/textart"
222	ARTSHUF=$(find "$ARTDIR" -type f | shuf -n1)
223
224	for art in $ARTSHUF; do
225		arttime --nolearn -a "$art" --ac 5
226	done
227}
228
229# to get quick notifs
230# after long commands
231notif() {
232	notify-send "done!"
233	sfx chime
234	spd-say -t female3 -r +25 "done!"
235}
236
237# shamelessly stolen from evan hahn:
238# https://evanhahn.com/scripts-i-wrote-that-i-use-all-the-time/#audio-and-video-and-pictures
239boop() {
240	local last="$?"
241	if [[ "$last" == "0" ]]; then
242		sfx chime
243	else
244		sfx bad
245	fi
246	exit "$last"
247}
248
249# make & cd into a folder
250mkcd() {
251  mkdir -p "$@" && cd "$_" || exit 1;
252}
253
254# man by default, fall back to `help`
255# for shell functions
256# https://lobste.rs/s/fkr3ha/some_terminal_frustrations#c_70wike
257man() {
258	/usr/bin/man "$@" || help "$@" | less
259}
260
261# https://askubuntu.com/questions/196890/how-to-find-the-bitrate-of-an-mp3-file-via-command-line
262bitrate() {
263	gum style --foreground "#f4b8e4" "file: " | tr -d "\n"
264	basename "$1"
265	gum style --foreground "#f4b8e4" "bitrate: " | tr -d "\n"
266	echo "$(file "$1" | sed 's/.*, \(.*\)kbps.*/\1/' | tr -d " " )" kbps
267}
268
269######################################
270# misc
271######################################
272
273eval "$(starship init bash)"
274eval "$(fzf --bash)"
275eval "$(batman --export-env)"
276
277if command -v zmx &> /dev/null; then
278  eval "$(zmx completions bash)"
279fi