main dots / config / .bashrc-mariposa
xxwhirlpool  ·  2026-09-03
  1#!/bin/bash
  2# ~/.bashrc: executed by bash(1) for non-login shells.
  3# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
  4# for examples
  5
  6######################################
  7# default stuff i'm scared to change
  8######################################
  9
 10# If not running interactively, don't do anything
 11case $- in
 12    *i*) ;;
 13      *) return;;
 14esac
 15
 16HISTCONTROL=ignoreboth
 17
 18# append to the history file, don't overwrite it
 19shopt -s histappend
 20
 21HISTSIZE=1000
 22HISTFILESIZE=2000
 23
 24# check the window size after each command and, if necessary,
 25# update the values of LINES and COLUMNS.
 26shopt -s checkwinsize
 27
 28# make less more friendly for non-text input files, see lesspipe(1)
 29[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
 30
 31# set variable identifying the chroot you work in (used in the prompt below)
 32if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
 33    debian_chroot=$(cat /etc/debian_chroot)
 34fi
 35
 36# set a fancy prompt (non-color, unless we know we "want" color)
 37case "$TERM" in
 38    xterm-color|*-256color) color_prompt=yes;;
 39esac
 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 (you don't need to enable
 73# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
 74# sources /etc/bash.bashrc).
 75if ! shopt -oq posix; then
 76  if [ -f /usr/share/bash-completion/bash_completion ]; then
 77    . /usr/share/bash-completion/bash_completion
 78  elif [ -f /etc/bash_completion ]; then
 79    . /etc/bash_completion
 80  fi
 81fi
 82
 83######################################
 84# aliases
 85######################################
 86
 87# general
 88alias icat="kitty +kitten icat"
 89alias fd="fdfind"
 90alias neofetch="hyfetch"
 91alias fastfetch="hyfetch"
 92alias bat="batcat"
 93alias cat="bat --paging=never"
 94alias rced="micro ~/.bashrc && source ~/.bashrc"
 95alias ps="ps auxww"
 96alias dd="askdd"
 97alias copy="xclip -sel clipboard"
 98alias open="xdg-open &>/dev/null"
 99alias c="clear"
100alias updupgr="sudo apt update && sudo apt upgrade"
101alias freeze="freeze -c user"
102alias glow="glow -p"
103alias unfuckwifi="sudo systemctl restart NetworkManager"
104alias uptime="uptime -p"
105alias irc="senpai"
106alias xmpp="profanity"
107alias email="neomutt"
108alias ip="ip -c"
109
110# some cd bookmarks
111alias dotf="cd /home/kat/dotfiles"
112alias gmine="cd /home/kat/Projects/mine"
113alias scr="cd /home/kat/Scripts"
114
115# weather stuff
116alias wttr="curl https://wttr.in/nyc?F0Au"
117alias weather="wttr"
118alias wttrlg="curl https://wttr.in/nyc?F1uq"
119alias weatherlg="wttrlg"
120alias sun="daylight --short --timezone='America/New_York'"
121
122# git
123alias gitall="git remote | xargs -L1 git push --all"
124alias gyolo="git add . && git commit -m 'yolo'"
125alias gitd="git diff --staged"
126alias gitlc="git diff HEAD~"
127alias gdiff="gitd"
128alias gits="git status"
129alias gita="git add ."
130
131# dev
132alias irb="rv run irb"
133alias ipy="python3 -i"
134
135# vpn split tunnel aliases based on a small script @ ~/.local/bin/mvpn
136alias mftp="mvpn filezilla"
137alias mterm="mvpn kitty"
138
139# servers
140alias kssh="kitty +kitten ssh" # fujo, fujoat, goldstar, ncc1701
141
142######################################
143# variables
144######################################
145
146export PATH=$PATH:/usr/local/go/bin
147
148export NVM_DIR="$HOME/.config/nvm"
149[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
150[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
151
152# set truecolor
153export COLORTERM=truecolor
154export MICRO_TRUECOLOR=1
155
156# catppuccin colors for fzf
157export FZF_DEFAULT_OPTS=" \
158--color=spinner:#F2D5CF,hl:#E78284 \
159--color=fg:#C6D0F5,header:#E78284,info:#CA9EE6,pointer:#F2D5CF \
160--color=marker:#BABBF1,fg+:#C6D0F5,prompt:#CA9EE6,hl+:#E78284 \
161--color=border:#414559,label:#C6D0F5"
162
163export FZF_CTRL_T_OPTS="
164  --walker-skip .git,node_modules,target
165  --preview 'batcat -n --color=always {}'
166  --bind 'ctrl-/:change-preview-window(down|hidden|)'"
167
168export FZF_ALT_C_OPTS="
169  --walker-skip .git,node_modules,target
170  --preview 'tree -C {}'"
171
172export LEDGER_FILE=~/.config/hledger/katmoney.journal
173
174# perl shit
175PATH="/home/kat/.perl5/bin${PATH:+:${PATH}}"; export PATH;
176PERL5LIB="/home/kat/.perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB;
177PERL_LOCAL_LIB_ROOT="/home/kat/.perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT;
178PERL_MB_OPT="--install_base \"/home/kat/.perl5\""; export PERL_MB_OPT;
179PERL_MM_OPT="INSTALL_BASE=/home/kat/.perl5"; export PERL_MM_OPT;
180
181export PERLBREW_ROOT="$HOME/.perl5/perlbrew"
182source "$PERLBREW_ROOT/etc/bashrc"
183
184# golang shit
185export GOPATH="$HOME/.go"
186
187# editor
188export EDITOR="/usr/bin/micro"
189
190######################################
191# functions
192######################################
193
194# print internal & external IPs
195whatip() {
196	# internal
197	gum style --foreground 212 "internal IP: "
198	hostname -I | awk '{print $1}'
199
200	# external
201	gum style --foreground 212 "external IP: "
202	curl -4 icanhazip.com
203}
204
205# password generator. takes input for password length by number
206passgen() {
207	PASSLENGTH=$(gum input --placeholder "type a number")
208	date +%s | sha256sum | base64 | head -c "$PASSLENGTH"; echo
209}
210
211cdmess() {
212	# from this blog post:
213	# https://blog.larah.me/mess-directory/
214	today_tmpdir="${TMPDIR-/tmp}/${USER}_mess/$(date +%F)"
215	mkdir -p "$today_tmpdir"
216	cd "$(mktemp -d -p "${today_tmpdir}" XXXX)" || exit 1
217}
218
219# to get quick notifs
220# after long commands
221notif() {
222	notify-send "done!"
223	sfx chime
224	spd-say -t female3 -r +25 "done!"
225}
226
227# make & cd into a folder
228mkcd() {
229  mkdir -p "$@" && cd "$_" || exit 1;
230}
231
232# shamelessly stolen from evan hahn:
233# https://evanhahn.com/scripts-i-wrote-that-i-use-all-the-time/#audio-and-video-and-pictures
234boop() {
235	local last="$?"
236	if [[ "$last" == "0" ]]; then
237		sfx chime
238	else
239		sfx bad
240	fi
241	exit "$last"
242}
243
244# man by default, fall back to `help`
245# for shell functions
246# https://lobste.rs/s/fkr3ha/some_terminal_frustrations#c_70wike
247man() {
248	/usr/bin/man "$@" || help "$@" | less
249}
250
251# https://askubuntu.com/questions/196890/how-to-find-the-bitrate-of-an-mp3-file-via-command-line
252bitrate() {
253	gum style --foreground "#f4b8e4" "file: " | tr -d "\n"
254	basename "$1"
255	gum style --foreground "#f4b8e4" "bitrate: " | tr -d "\n"
256	echo "$(file "$1" | sed 's/.*, \(.*\)kbps.*/\1/' | tr -d " " )" kbps
257}
258
259portfree() {
260	while
261		port=$(shuf -n 1 -i 1024-65535)
262		netstat -atun | grep -q "$port"
263	do
264		continue
265	done
266	echo -n "$port"
267}
268
269######################################
270# misc
271######################################
272
273eval "$(starship init bash)"
274eval "$(fzf --bash)"
275eval "$(batman --export-env)"
276. "/home/kat/.deno/env"
277
278eval "$(/home/kat/.cargo/bin/rv shell init bash)"
279eval "$(/home/kat/.cargo/bin/rv shell completions bash)"
280
281if command -v zmx &> /dev/null; then
282  eval "$(zmx completions bash)"
283fi