main dots / config / .bashrc-kwangya
xxwhirlpool  ·  2026-09-28
  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 qrcode="qrencode -t ansiutf8"
 98alias ffmpeg="ffmpeg -hide_banner"
 99alias open="xdg-open"
100alias c="clear"
101alias unfuckwifi="sudo systemctl restart NetworkManager"
102alias uptime="uptime -p"
103alias irc="senpai"
104alias xmpp="profanity"
105alias email="aerc"
106alias updupgr="sudo apt update && sudo apt upgrade"
107alias winek="wineserver -k"
108alias docker="sudo docker"
109
110# weather stuff
111alias wttr="curl https://wttr.in/nyc?F0Au"
112alias weather="wttr"
113alias wttrlg="curl https://wttr.in/nyc?F1uq"
114alias weatherlg="wttrlg"
115alias sun="daylight --short --timezone='America/New_York' | lolcat"
116
117# git
118alias gitall="git remote | xargs -L1 git push --all"
119alias gyolo="git add . && git commit -m 'yolo'"
120alias gitd="git diff --staged"
121alias gdiff="gitd"
122alias gits="git status"
123alias gita="git add ."
124alias gitlc="git diff HEAD~"
125
126# dev
127alias irb="rv run irb"
128alias ipy="python3 -i"
129
130# vpn split tunnel aliases based on a small script @ ~/.local/bin/mvpn
131alias mftp="mvpn filezilla"
132alias mterm="mvpn kitty"
133
134# cd bookmarks
135alias dotf="cd /home/kat/dotfiles"
136alias gmine="cd /home/kat/Projects/mine"
137alias scr="cd /home/kat/Scripts"
138
139# servers
140alias kssh="kitty +kitten ssh" # fujo, fujoat, goldstar, ncc1701
141
142######################################
143# variables
144######################################
145
146export EDITOR=/usr/local/bin/micro
147export "MICRO_TRUECOLOR=1"
148
149export BROWSER=librewolf
150 
151# catppuccin colors for fzf
152export FZF_DEFAULT_OPTS=" \
153--color=spinner:#F2D5CF,hl:#E78284 \
154--color=fg:#C6D0F5,header:#E78284,info:#CA9EE6,pointer:#F2D5CF \
155--color=marker:#BABBF1,fg+:#C6D0F5,prompt:#CA9EE6,hl+:#E78284 \
156--color=border:#414559,label:#C6D0F5 \
157--preview 'batcat --color=always --line-range :500 --style=numbers {}'"
158
159# change default search cmd from `find` to `fd`
160export FZF_DEFAULT_COMMAND="fd --type f"
161
162# Created by `pipx` on 2025-08-05 03:36:48
163export PATH="$PATH:/home/kat/dotfiles/config/.local/bin"
164export PATH=$PATH:/usr/local/go/bin
165
166export NVM_DIR="$HOME/.config/nvm"
167[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
168[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
169
170. "$HOME/.cargo/env"
171
172. "/home/kat/.deno/env"
173
174export GOPATH="/home/kat/.godir"
175
176export GNUPGHOME="/home/kat/.config/gnupg"
177
178export ADDRBOOK_PATH="$HOME/.local/addrbook"
179export PATH="$PATH:$HOME/.local/addrbook"
180
181export PATH="$PATH:$HOME/Scripts/perl"
182export PATH="$PATH:$HOME/Scripts/python"
183export PATH="$PATH:$HOME/Scripts/ruby"
184export PATH="$PATH:$HOME/Scripts/shell"
185
186export PATH="$PATH:$HOME/Projects/mine/urlref.pl"
187
188######################################
189# functions
190######################################
191
192cdmess() {
193	# from this blog post:
194	# https://blog.larah.me/mess-directory/
195    today_tmpdir="${TMPDIR-/tmp}/${USER}_mess/$(date +%F)"
196    mkdir -p "$today_tmpdir"
197    cd "$(mktemp -d -p "${today_tmpdir}" XXXX)" || exit 1
198}
199 
200# get a random free port. this is useful for my
201# insane sysadmin website woman adventures
202portfree() {
203	while
204		port=$(shuf -n 1 -i 1024-65535)
205		netstat -atun | grep -q "$port"
206	do
207		continue
208	done
209	echo "$port"
210}
211 
212# print internal & external IPs
213whatip() {
214	# internal
215	echo -n "internal IP: "
216	hostname -I | awk '{print $1}'
217
218	# external
219	echo -n "external IP: "
220	curl -4 icanhazip.com
221}
222 
223# password generator. takes input for password length by number
224passgen() {
225	PASSLENGTH=$(gum input --placeholder "type a number")
226	date +%s | sha256sum | base64 | head -c "$PASSLENGTH"; echo
227}
228
229# display random ASCII art from
230# custom dir of art in dotfiles
231# using arttime (github: poetaman/arttime)
232playart() {
233	ARTDIR="/home/kat/dotfiles/config/.local/share/arttime/textart"
234	ARTSHUF=$(find "$ARTDIR" -type f | shuf -n1)
235
236	for art in $ARTSHUF; do
237		arttime --nolearn -a "$art" --ac 5
238	done
239}
240
241# to get quick notifs
242# after long commands
243notif() {
244	notify-send "done!"
245	sfx chime
246	spd-say -t female3 -r +25 "done!"
247}
248
249# shamelessly stolen from evan hahn:
250# https://evanhahn.com/scripts-i-wrote-that-i-use-all-the-time/#audio-and-video-and-pictures
251boop() {
252	local last="$?"
253	if [[ "$last" == "0" ]]; then
254		sfx chime
255	else
256		sfx bad
257	fi
258	exit "$last"
259}
260
261# make & cd into a folder
262mkcd() {
263  mkdir -p "$@" && cd "$_" || exit 1;
264}
265
266# man by default, fall back to `help`
267# for shell functions
268# https://lobste.rs/s/fkr3ha/some_terminal_frustrations#c_70wike
269man() {
270	/usr/bin/man "$@" || help "$@" | less
271}
272
273# https://askubuntu.com/questions/196890/how-to-find-the-bitrate-of-an-mp3-file-via-command-line
274bitrate() {
275	gum style --foreground "#f4b8e4" "file: " | tr -d "\n"
276	basename "$1"
277	gum style --foreground "#f4b8e4" "bitrate: " | tr -d "\n"
278	echo "$(file "$1" | sed 's/.*, \(.*\)kbps.*/\1/' | tr -d " " )" kbps
279}
280
281# this wouldn't work in a script
282# so it's here
283catfunc() {
284	declare -f "$1" || echo "$1 does not exist"
285}
286
287######################################
288# misc
289######################################
290
291eval "$(starship init bash)"
292eval "$(fzf --bash)"
293eval "$(batman --export-env)"
294
295if command -v zmx &> /dev/null; then
296  eval "$(zmx completions bash)"
297fi