187 lines
5.7 KiB
Bash
187 lines
5.7 KiB
Bash
# ==============================================================================
|
|
# ENVIRONMENT VARIABLES
|
|
# ==============================================================================
|
|
|
|
export XDG_CONFIG_HOME="$HOME/.config"
|
|
export XDG_DATA_HOME="$HOME/.local/share"
|
|
export XDG_CACHE_HOME="$HOME/.cache"
|
|
export XDG_STATE_HOME="$HOME/.local/state"
|
|
export GOOGLE_API_KEY="no"
|
|
export GOOGLE_DEFAULT_CLIENT_ID="no"
|
|
export GOOGLE_DEFAULT_CLIENT_SECRET="no"
|
|
|
|
# Core settings
|
|
export EDITOR="nvim"
|
|
export VISUAL="nvim"
|
|
export MANPAGER="nvim +Man!"
|
|
export BROWSER="firefox"
|
|
# export TERM=xterm-256color
|
|
export COLORTERM="truecolor"
|
|
export LANG="en_US.UTF-8"
|
|
export LC_ALL="en_US.UTF-8"
|
|
|
|
# Development
|
|
export DEBUG=1
|
|
export GOPATH="$HOME/.go"
|
|
export GOCACHE="$HOME/.go/cache"
|
|
export GOROOT=/usr/local/go
|
|
export PATH="/usr/local/go/bin:$GOPATH/bin:$PATH"
|
|
|
|
# Direnv
|
|
eval "$(direnv hook bash)"
|
|
|
|
# ==============================================================================
|
|
# FZF configuration
|
|
# ==============================================================================
|
|
export FZF_DEFAULT_OPTS="
|
|
--height 40%
|
|
--layout=reverse
|
|
--border
|
|
--ansi
|
|
--preview-window=down:30%
|
|
--bind 'ctrl-d:preview-page-down,ctrl-u:preview-page-up'
|
|
--color=fg:#ffffff,header:#f38ba8,info:#cba6ac,pointer:#f5e0dc
|
|
--color=marker:#f5e0dc,fg+:#cdd6f4,prompt:#cba6ac,hl+:#f38ba8"
|
|
|
|
export FZF_DEFAULT_COMMAND='fdfind --exclude={.git,.cache,.xmake,.zig-cache,build,tmp,node_modules,elpa} --type f -H'
|
|
|
|
# ==============================================================================
|
|
# PATH CONFIGURATION
|
|
# ==============================================================================
|
|
# bash has no fish_add_path (which dedupes + checks existence), so roll a
|
|
# small helper that does the same thing.
|
|
add_to_path() {
|
|
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
|
|
PATH="$1:$PATH"
|
|
fi
|
|
}
|
|
|
|
add_to_path /var/lib/flatpak/exports/bin
|
|
add_to_path /usr/local/bin
|
|
add_to_path /usr/local/go/bin
|
|
add_to_path "$GOPATH/bin"
|
|
add_to_path "$HOME/bin"
|
|
add_to_path "$HOME/.local/bin"
|
|
add_to_path "$HOME/.local/share/flatpak/exports/bin"
|
|
add_to_path "$HOME/.npm-global/bin"
|
|
add_to_path "$HOME/.odin/"
|
|
|
|
export PATH
|
|
|
|
# ==============================================================================
|
|
# AUTO COMPLETE
|
|
# ==============================================================================
|
|
if [ -f /usr/share/bash-completion/bash_completion ]; then
|
|
. /usr/share/bash-completion/bash_completion
|
|
fi
|
|
|
|
# ==============================================================================
|
|
# ALIASES
|
|
# ==============================================================================
|
|
# Void linux helpers
|
|
# System update (sync + update all packages)
|
|
alias void-update='sudo xbps-install -Su'
|
|
# Remove orphaned dependencies + clean cache
|
|
alias void-clean='sudo xbps-remove -Oo'
|
|
# List explicitly installed (manual) packages
|
|
alias void-installed='xbps-query -m'
|
|
# List all installed packages
|
|
alias void-installedall='xbps-query -l'
|
|
# Show which package owns a file
|
|
alias void-owns='xbps-query -o'
|
|
# Remove a package and its unused deps in one go (usage: purge <pkgname>)
|
|
alias void-purge='sudo xbps-remove -R'
|
|
# Install a package (usage: install <pkgname>)
|
|
alias void-install='sudo xbps-install'
|
|
# Remove a package (usage: remove <pkgname>)
|
|
alias void-remove='sudo xbps-remove'
|
|
# Search for a package
|
|
alias void-search='xbps-query -Rs'
|
|
# Show info about a package
|
|
alias void-query='xbps-query -R'
|
|
|
|
# List commands
|
|
alias ls='ls -lh --color=auto --group-directories-first'
|
|
alias ll='ls -lAh --color=auto --group-directories-first'
|
|
alias la='ls -la --color=auto --group-directories-first'
|
|
alias l='ls -CF --color=auto'
|
|
alias tree='tree --dirsfirst -C'
|
|
|
|
# Safety aliases
|
|
alias rm='rm -I --preserve-root'
|
|
alias mv='mv -i'
|
|
alias cp='cp -i'
|
|
alias ln='ln -i'
|
|
|
|
# System information
|
|
alias df='df -h'
|
|
alias du='du -h'
|
|
alias free='free -h'
|
|
alias bat='bat --theme="ansi" --paging=never'
|
|
|
|
# Application shortcuts
|
|
alias vi='nvim'
|
|
alias :q='exit'
|
|
alias files='thunar .'
|
|
alias fetch='pfetch'
|
|
|
|
# Custom shortcuts
|
|
alias reload='source ~/.bashrc'
|
|
alias dots='cd ~/.dotfiles && nvim'
|
|
alias doti='bash ~/.dotfiles/install.sh -i'
|
|
alias dotl='bash ~/.dotfiles/install.sh -l'
|
|
alias myip='curl ipinfo.io/ip; echo ""'
|
|
alias query='xbps-query -Rs'
|
|
alias commits='git log origin/main..HEAD --oneline'
|
|
|
|
## Basic project picker using fzf
|
|
pp() {
|
|
local project
|
|
project=$(
|
|
find ~/Projects -mindepth 1 -maxdepth 1 -type d |
|
|
awk -F/ '{print $NF "\t" $0}' |
|
|
fzf --with-nth=1
|
|
)
|
|
|
|
[ -z "$project" ] && return
|
|
|
|
project=$(echo "$project" | cut -f2)
|
|
cd "$project" && clear
|
|
}
|
|
|
|
# ==============================================================================
|
|
# PROMPT
|
|
# ==============================================================================
|
|
# bash has no built-in __fish_git_prompt_* equivalent, so we write a small
|
|
# git-branch function and build PS1 by hand.
|
|
|
|
parse_git_branch() {
|
|
git branch 2>/dev/null | sed -n '/\* /s///p'
|
|
}
|
|
|
|
git_prompt_info() {
|
|
local branch
|
|
branch=$(parse_git_branch)
|
|
[ -z "$branch" ] && return
|
|
|
|
local esc=$'\033'
|
|
local status marker
|
|
status=$(git status --porcelain 2>/dev/null)
|
|
|
|
if [ -n "$status" ]; then
|
|
if echo "$status" | grep -q '^[MADRC]'; then
|
|
marker=" ${esc}[33m●${esc}[0m " # staged - yellow ●
|
|
elif echo "$status" | grep -q '^??'; then
|
|
marker="" # untracked - no char
|
|
else
|
|
marker=" ${esc}[31m+${esc}[0m " # dirty - red +
|
|
fi
|
|
else
|
|
marker=" ${esc}[1;32m${esc}[0m " # clean - green
|
|
fi
|
|
|
|
echo " ${esc}[1;35m(${branch})${esc}[0m${marker}"
|
|
}
|
|
|
|
PS1='\[\033[32m\]\u\[\033[0m\]@\[\033[34m\]\h\[\033[0m\]:\[\033[36m\]\w\[\033[0m\]$(git_prompt_info)\$ '
|