feat: add bash config
491bf0b9
2 file(s) · +226 −0
| 1 | + | # ~/.bash_profile |
|
| 2 | + | # Login shells read this, not ~/.bashrc. |
|
| 3 | + | # Source ~/.bashrc so interactive config loads either way. |
|
| 4 | + | [ -f ~/.bashrc ] && . ~/.bashrc |
| 1 | + | # ~/.bashrc — mirrors the nushell config |
|
| 2 | + | # |
|
| 3 | + | # Linked via: fling link -s bash -l ~ |
|
| 4 | + | ||
| 5 | + | # Interactive-only guard |
|
| 6 | + | case $- in |
|
| 7 | + | *i*) ;; |
|
| 8 | + | *) return ;; |
|
| 9 | + | esac |
|
| 10 | + | ||
| 11 | + | # ============================================================================= |
|
| 12 | + | # History |
|
| 13 | + | # ============================================================================= |
|
| 14 | + | HISTSIZE=100000 |
|
| 15 | + | HISTFILESIZE=100000 |
|
| 16 | + | HISTCONTROL=ignoreboth |
|
| 17 | + | shopt -s histappend |
|
| 18 | + | ||
| 19 | + | # vi mode (matches nushell edit_mode: vi) |
|
| 20 | + | set -o vi |
|
| 21 | + | ||
| 22 | + | # ============================================================================= |
|
| 23 | + | # Environment |
|
| 24 | + | # ============================================================================= |
|
| 25 | + | export EDITOR="nvim" |
|
| 26 | + | export CLICOLOR=1 |
|
| 27 | + | ||
| 28 | + | # Go |
|
| 29 | + | export GOROOT="/usr/local/go" |
|
| 30 | + | export GOPATH="$HOME/.local/share/go" |
|
| 31 | + | export GOMODCACHE="$HOME/.local/share/go-mod-cache" |
|
| 32 | + | #export GOPRIVATE="*gitlab*" |
|
| 33 | + | ||
| 34 | + | # bat |
|
| 35 | + | export BAT_THEME="ansi" |
|
| 36 | + | export BAT_THEME_DARK="ansi" |
|
| 37 | + | ||
| 38 | + | # gpg |
|
| 39 | + | export GPG_TTY="$(tty)" |
|
| 40 | + | ||
| 41 | + | # misc |
|
| 42 | + | export BULLETS_FEEDS="feeds.stevedylan.dev/feed.xml" |
|
| 43 | + | export FLOW_BOARD_PATH="$HOME/notes/board" |
|
| 44 | + | ||
| 45 | + | # pnpm |
|
| 46 | + | export PNPM_HOME="$HOME/.local/share/pnpm" |
|
| 47 | + | ||
| 48 | + | # fzf |
|
| 49 | + | export FZF_DEFAULT_COMMAND='fd --type f --hidden --exclude ".git"' |
|
| 50 | + | export FZF_DEFAULT_OPTS=' |
|
| 51 | + | --color=fg:8:bold,fg+:15,bg:-1,bg+:-1 |
|
| 52 | + | --color=hl:10:bold,hl+:10:bold |
|
| 53 | + | --color=info:8,spinner:9,header:4 |
|
| 54 | + | --color=prompt:2,pointer:9,marker:1 |
|
| 55 | + | --color=border:7,label:15:bold,query:15 |
|
| 56 | + | --border="rounded" |
|
| 57 | + | --border-label="" |
|
| 58 | + | --preview-window="border-rounded" |
|
| 59 | + | --prompt="> " |
|
| 60 | + | --marker=" " |
|
| 61 | + | --pointer="◆" |
|
| 62 | + | --separator="" |
|
| 63 | + | --scrollbar="" |
|
| 64 | + | --gutter=" " |
|
| 65 | + | --info=inline-right' |
|
| 66 | + | ||
| 67 | + | # ============================================================================= |
|
| 68 | + | # PATH |
|
| 69 | + | # ============================================================================= |
|
| 70 | + | # path_add <dir>: prepend if not already present and dir exists |
|
| 71 | + | path_add() { |
|
| 72 | + | case ":$PATH:" in |
|
| 73 | + | *":$1:"*) ;; |
|
| 74 | + | *) [ -d "$1" ] && PATH="$1:$PATH" ;; |
|
| 75 | + | esac |
|
| 76 | + | } |
|
| 77 | + | ||
| 78 | + | path_add "/home/linuxbrew/.linuxbrew/bin" |
|
| 79 | + | path_add "/usr/local/go/bin" |
|
| 80 | + | path_add "$HOME/.cargo/bin" |
|
| 81 | + | path_add "$HOME/.local/share/go/bin" |
|
| 82 | + | path_add "$HOME/.local/bin" |
|
| 83 | + | path_add "/usr/local/bin" |
|
| 84 | + | path_add "$HOME/.bun/bin" |
|
| 85 | + | path_add "$HOME/.deno/bin" |
|
| 86 | + | path_add "$HOME/.foundry/bin" |
|
| 87 | + | path_add "$HOME/.local/share" |
|
| 88 | + | path_add "$HOME/.local/share/solana/install/active_release/bin" |
|
| 89 | + | path_add "$HOME/.radicle/bin" |
|
| 90 | + | path_add "$HOME/.nargo/bin" |
|
| 91 | + | path_add "$HOME/.aztec/bin" |
|
| 92 | + | path_add "$HOME/.helios/bin" |
|
| 93 | + | path_add "$HOME/.tmux/plugins/t-smart-tmux-session-manager/bin" |
|
| 94 | + | path_add "$PNPM_HOME" |
|
| 95 | + | ||
| 96 | + | export PATH |
|
| 97 | + | ||
| 98 | + | # fnm (node version manager) |
|
| 99 | + | if command -v fnm >/dev/null 2>&1; then |
|
| 100 | + | eval "$(fnm env --shell bash)" |
|
| 101 | + | path_add "$FNM_MULTISHELL_PATH/bin" |
|
| 102 | + | export PATH |
|
| 103 | + | # auto-switch node version on cd when .node-version / .nvmrc present |
|
| 104 | + | __fnm_autouse() { |
|
| 105 | + | if [ -f .node-version ] || [ -f .nvmrc ]; then |
|
| 106 | + | fnm use --silent-if-unchanged 2>/dev/null |
|
| 107 | + | fi |
|
| 108 | + | } |
|
| 109 | + | PROMPT_COMMAND="__fnm_autouse${PROMPT_COMMAND:+; $PROMPT_COMMAND}" |
|
| 110 | + | fi |
|
| 111 | + | ||
| 112 | + | # cargo |
|
| 113 | + | [ -f "$HOME/.cargo/env" ] && . "$HOME/.cargo/env" |
|
| 114 | + | ||
| 115 | + | # ============================================================================= |
|
| 116 | + | # Aliases |
|
| 117 | + | # ============================================================================= |
|
| 118 | + | alias ll='ls -l' |
|
| 119 | + | alias la='ls -a' |
|
| 120 | + | alias lg='lazygit' |
|
| 121 | + | alias nf='neofetch' |
|
| 122 | + | alias fl='fastfetch -c ~/.config/fastfetch/presets/examples/8.jsonc' |
|
| 123 | + | alias ff='fastfetch -c ~/.config/fastfetch/presets/examples/20.jsonc' |
|
| 124 | + | alias nvimrc='nvim ~/.config/nvim' |
|
| 125 | + | alias shitter='ssh itter' |
|
| 126 | + | alias ai='aichat' |
|
| 127 | + | alias system='macchina' |
|
| 128 | + | alias bonsai='cbonsai -li -t 0.4' |
|
| 129 | + | alias lst='lstr --icons --color=always --size' |
|
| 130 | + | alias keys='keysmasher' |
|
| 131 | + | alias timestamp='node -e "process.stdout.write(new Date().toISOString())"' |
|
| 132 | + | ||
| 133 | + | # tailscale is in PATH natively on linux (no app bundle alias needed) |
|
| 134 | + | ||
| 135 | + | # ============================================================================= |
|
| 136 | + | # Functions |
|
| 137 | + | # ============================================================================= |
|
| 138 | + | # Open a sesh session via gum filter |
|
| 139 | + | t() { |
|
| 140 | + | local selected |
|
| 141 | + | selected=$(sesh list -i | gum filter --limit 1 --placeholder "Choose a session" --height 50 --prompt="> " --indicator.foreground="2" --match.foreground="2") |
|
| 142 | + | if [ -z "$selected" ]; then |
|
| 143 | + | echo "No session selected" |
|
| 144 | + | else |
|
| 145 | + | sesh connect "$selected" |
|
| 146 | + | fi |
|
| 147 | + | } |
|
| 148 | + | ||
| 149 | + | # Fuzzy-find a file and open in nvim |
|
| 150 | + | nvimf() { |
|
| 151 | + | local file |
|
| 152 | + | file=$(fd --type f --hidden --exclude .git | fzf --preview "bat --color=always {}") |
|
| 153 | + | if [ -z "$file" ]; then |
|
| 154 | + | echo "No file selected" |
|
| 155 | + | else |
|
| 156 | + | nvim "$file" |
|
| 157 | + | fi |
|
| 158 | + | } |
|
| 159 | + | ||
| 160 | + | # Install a tree-sitter parser into the nvim luarocks tree |
|
| 161 | + | tsi() { |
|
| 162 | + | local parser="$1" |
|
| 163 | + | local tree="$HOME/.local/share/nvim/site" |
|
| 164 | + | luarocks --lua-version=5.1 "--tree=$tree" install "tree-sitter-$parser" |
|
| 165 | + | } |
|
| 166 | + | ||
| 167 | + | # nvim startup time -> grep summary line |
|
| 168 | + | ns() { |
|
| 169 | + | rm -f ~/.nvim-startup.txt |
|
| 170 | + | nvim --headless --startuptime ~/.nvim-startup.txt +qa |
|
| 171 | + | grep "NVIM STARTED" ~/.nvim-startup.txt |
|
| 172 | + | } |
|
| 173 | + | ||
| 174 | + | # nvim startup time -> full bat dump |
|
| 175 | + | nh() { |
|
| 176 | + | rm -f ~/.nvim-startup.txt |
|
| 177 | + | nvim --headless --startuptime ~/.nvim-startup.txt +qa |
|
| 178 | + | bat ~/.nvim-startup.txt |
|
| 179 | + | } |
|
| 180 | + | ||
| 181 | + | # Copy file contents to clipboard |
|
| 182 | + | cpf() { |
|
| 183 | + | if command -v wl-copy >/dev/null 2>&1; then |
|
| 184 | + | wl-copy < "$1" |
|
| 185 | + | elif command -v xclip >/dev/null 2>&1; then |
|
| 186 | + | xclip -selection clipboard < "$1" |
|
| 187 | + | elif command -v xsel >/dev/null 2>&1; then |
|
| 188 | + | xsel --clipboard --input < "$1" |
|
| 189 | + | else |
|
| 190 | + | echo "No clipboard tool found (wl-copy/xclip/xsel)" >&2 |
|
| 191 | + | return 1 |
|
| 192 | + | fi |
|
| 193 | + | echo "✔︎ Copied to clipboard!" |
|
| 194 | + | } |
|
| 195 | + | ||
| 196 | + | # Set orbiter key to personal |
|
| 197 | + | orbiter-personal() { |
|
| 198 | + | gum spin --spinner dot --spinner.foreground="2" --title "Updating..." -- orbiter auth --key "$(op read 'op://Personal/orbiter-api-key/credential')" |
|
| 199 | + | local check |
|
| 200 | + | check=$(gum style --foreground="2" "✓ ") |
|
| 201 | + | gum join "$check" "Orbiter key set to personal!" |
|
| 202 | + | } |
|
| 203 | + | ||
| 204 | + | # Set orbiter key to orbiter account |
|
| 205 | + | orbiter-account() { |
|
| 206 | + | gum spin --spinner dot --spinner.foreground="2" --title "Updating..." -- orbiter auth --key "$(op read 'op://Personal/orbiter-account-api-key/credential')" |
|
| 207 | + | local check |
|
| 208 | + | check=$(gum style --foreground="2" "✓ ") |
|
| 209 | + | gum join "$check" "Orbiter key set to Orbiter account!" |
|
| 210 | + | } |
|
| 211 | + | ||
| 212 | + | # UTC timestamp for blog frontmatter |
|
| 213 | + | blogdate() { |
|
| 214 | + | date -u +"%Y-%m-%dT%H:%M:%SZ" |
|
| 215 | + | } |
|
| 216 | + | ||
| 217 | + | # ============================================================================= |
|
| 218 | + | # Tooling init |
|
| 219 | + | # ============================================================================= |
|
| 220 | + | command -v zoxide >/dev/null 2>&1 && eval "$(zoxide init bash)" |
|
| 221 | + | command -v starship >/dev/null 2>&1 && eval "$(starship init bash)" |
|
| 222 | + | command -v fzf >/dev/null 2>&1 && eval "$(fzf --bash)" |