main dots / config / .bashrc-mariposa
xxwhirlpool  ·  2026-07-25
  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
181# golang shit
182export GOPATH="$HOME/.go"
183
184# editor
185export EDITOR="/usr/bin/micro"
186
187######################################
188# functions
189######################################
190
191# print internal & external IPs
192whatip() {
193	# internal
194	gum style --foreground 212 "internal IP: "
195	hostname -I | awk '{print $1}'
196
197	# external
198	gum style --foreground 212 "external IP: "
199	curl -4 icanhazip.com
200}
201
202# password generator. takes input for password length by number
203passgen() {
204	PASSLENGTH=$(gum input --placeholder "type a number")
205	date +%s | sha256sum | base64 | head -c "$PASSLENGTH"; echo
206}
207
208cdmess() {
209	# from this blog post:
210	# https://blog.larah.me/mess-directory/
211	today_tmpdir="${TMPDIR-/tmp}/${USER}_mess/$(date +%F)"
212	mkdir -p "$today_tmpdir"
213	cd "$(mktemp -d -p "${today_tmpdir}" XXXX)" || exit 1
214}
215
216# to get quick notifs
217# after long commands
218notif() {
219	notify-send "done!"
220	sfx chime
221	spd-say -t female3 -r +25 "done!"
222}
223
224# make & cd into a folder
225mkcd() {
226  mkdir -p "$@" && cd "$_" || exit 1;
227}
228
229# shamelessly stolen from evan hahn:
230# https://evanhahn.com/scripts-i-wrote-that-i-use-all-the-time/#audio-and-video-and-pictures
231boop() {
232	local last="$?"
233	if [[ "$last" == "0" ]]; then
234		sfx chime
235	else
236		sfx bad
237	fi
238	exit "$last"
239}
240
241# man by default, fall back to `help`
242# for shell functions
243# https://lobste.rs/s/fkr3ha/some_terminal_frustrations#c_70wike
244man() {
245	/usr/bin/man "$@" || help "$@" | less
246}
247
248# https://askubuntu.com/questions/196890/how-to-find-the-bitrate-of-an-mp3-file-via-command-line
249bitrate() {
250	gum style --foreground "#f4b8e4" "file: " | tr -d "\n"
251	basename "$1"
252	gum style --foreground "#f4b8e4" "bitrate: " | tr -d "\n"
253	echo "$(file "$1" | sed 's/.*, \(.*\)kbps.*/\1/' | tr -d " " )" kbps
254}
255
256portfree() {
257	while
258		port=$(shuf -n 1 -i 1024-65535)
259		netstat -atun | grep -q "$port"
260	do
261		continue
262	done
263	echo -n "$port"
264}
265
266######################################
267# misc
268######################################
269
270eval "$(starship init bash)"
271eval "$(fzf --bash)"
272eval "$(batman --export-env)"
273. "/home/kat/.deno/env"
274
275eval "$(/home/kat/.cargo/bin/rv shell init bash)"
276eval "$(/home/kat/.cargo/bin/rv shell completions bash)"
277
278if command -v zmx &> /dev/null; then
279  eval "$(zmx completions bash)"
280fi