Misc updates

This commit is contained in:
David Tomaschik
2026-02-18 16:10:06 -08:00
parent cdbc40d1e8
commit 9ab1f9c298
14 changed files with 243 additions and 26 deletions

View File

@@ -1,22 +1,12 @@
# General aliases, should only be sourced in interactive shells
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# Cryptsetup alias
alias luksFormat='cryptsetup luksFormat --type=luks2 --pbkdf-memory=2560000 --pbkdf=argon2id -i 15000 -s 512 -h sha256 -c aes-xts-plain64'
# Colors
if ls --version >/dev/null 2>&1 ; then
alias ls='ls --color=auto'
fi
if [ `uname` != 'Darwin' -a `uname` != 'NetBSD' -a `uname` != 'FreeBSD' -a `uname` != 'OpenBSD' ] ; then
# Should have a better way to check for GNU versions
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
fi
# Easy upgrade
alias dist-upgrade="sudo sh -c 'apt-get update && apt-get -y dist-upgrade'"
@@ -30,8 +20,7 @@ alias mdcode="sed 's/^/ /'"
# Intel format plz
alias objdump="command objdump -M intel"
# Useful directory utilities
alias dircount="for d in * ; do find \$d -type d | wc -l | tr -d '\n' ; echo ' ' \$d ; done | sort -n"
# Drop caches for swap issues
alias drop_caches="echo 3 | sudo /usr/bin/tee /proc/sys/vm/drop_caches"
@@ -41,7 +30,7 @@ alias gettemp='printf "%02.2f\n" "$(cat /sys/class/thermal/thermal_zone0/temp)e-
# get git working directory
alias gitroot="git rev-parse --show-toplevel"
alias cdgr='cd $(git rev-parse --show-toplevel || echo .)'
# SSH without host key checking
alias sshanon="ssh -oUserKnownHostsFile=/dev/null -oStrictHostKeyChecking=no"

View File

@@ -0,0 +1,65 @@
# This script reads a bash-formatted alias file (~/.aliases) and creates
# equivalent fish aliases. This allows for sharing aliases between bash and fish.
# Path to the bash alias file
set bash_alias_file ~/.aliases
# Check if the alias file exists
if test -f "$bash_alias_file"
# Read the file line by line
while read -l line
# Skip comments and empty lines
if string match -q -r '^\s*#' "$line" || test -z "$line"
continue
end
# Check if the line defines an alias
if string match -q -r '^\s*alias\s+' "$line"
# Remove the 'alias ' prefix
set -l definition (string replace -r '^\s*alias\s+' '' "$line")
# Split the definition into name and value at the first '='
set -l parts (string split -m 1 '=' "$definition")
set -l alias_name $parts[1]
set -l alias_value $parts[2]
# Remove leading/trailing quotes from the value
set -l alias_value (string trim -c "'"" "$alias_value")
# Define the fish alias
alias $alias_name "$alias_value"
end
end < "$bash_alias_file"
end
# Specific aliases that are not in the bash file
# On some systems, bat is batcat
if not command -v bat >/dev/null 2>&1
if command -v batcat >/dev/null 2>&1
alias bat (command -v batcat)
end
end
# FFUF aliases
if command -v ffuf >/dev/null 2>&1
if test -d $HOME/tools/seclists
alias ffuf-files "ffuf -c -w $HOME/tools/seclists/Discovery/Web-Content/raft-large-files.txt"
alias ffuf-dirs "ffuf -c -w $HOME/tools/seclists/Discovery/Web-Content/raft-large-directories.txt"
alias ffuf-quick "ffuf -c -w $HOME/tools/seclists/Discovery/Web-Content/quickhits.txt"
end
end
if grep --help 2>/dev/null | grep -q 'color'
# Should have a better way to check for GNU versions
alias grep 'grep --color=auto'
alias egrep 'egrep --color=auto'
alias fgrep 'fgrep --color=auto'
end
# Detect which `ls` flavor is in use and use the right flag for colors.
if ls --help 2>&1 | grep -q -- '--color'
alias ls 'ls --color=auto' # GNU `ls`
else if test (uname) = "Darwin"
alias ls 'ls -G' # macOS `ls`
end

View File

@@ -7,6 +7,11 @@ if test -x /opt/homebrew/bin/brew
if test -d (brew --prefix)"/share/fish/vendor_completions.d"
set -p fish_complete_path (brew --prefix)/share/fish/vendor_completions.d
end
# mise, if installed
if type -q mise
mise hook fish | source
end
end
if command -q starship

View File

@@ -0,0 +1,8 @@
# Change to the root of the git repository.
# If not in a git repo, do nothing.
function cdgr
set git_root (git rev-parse --show-toplevel 2>/dev/null)
if test -n "$git_root"
cd "$git_root"
end
end

View File

@@ -0,0 +1,14 @@
[settings]
experimental = true
[settings.pipx]
uvx = true
[settings.python]
uv_venv_auto = true
[tools]
uv = "latest"
[hooks]
postinstall = "mise sync python --uv"

8
dotfiles/xbindkeysrc Normal file
View File

@@ -0,0 +1,8 @@
# Custom copy/paste mapping for Alt+C and Alt+V to feel more like macOS.
# Uses a helper script to send Shift for terminal applications.
"smart-copy-paste copy"
alt + c
"smart-copy-paste paste"
alt + v

View File

@@ -2,4 +2,5 @@ setxkbmap -option ctrl:nocaps -option compose:ralt
test -x /usr/bin/xsettingsd && /usr/bin/xsettingsd &
test -f "$HOME/.env" && "$HOME/.env"
test -f "$HOME/.shenv" && "$HOME/.shenv"
command -v xbindkeys >/dev/null && xbindkeys &
test -f "$HOME/.profile" && . "$HOME/.profile"

View File

@@ -1,8 +1,3 @@
# Execute code that does not affect the current session in the background.
{
# Compile the completion dump to increase startup speed.
zcompdump="${ZDOTDIR:-$HOME}/.zcompdump"
if [[ -s "$zcompdump" && (! -s "${zcompdump}.zwc" || "$zcompdump" -nt "${zcompdump}.zwc") ]]; then
zcompile "$zcompdump"
fi
} &!
# This file is sourced only for login shells (e.g., SSH sessions, initial TTY logins).
# For most interactive shells on macOS (like those in Terminal.app or iTerm2), it is NOT sourced.
# All active Zsh startup and completion logic has been moved to .zshrc and .zshenv for better consistency and performance.

View File

@@ -1,4 +1,8 @@
# For interactive shells
[[ -n "$ZSH_PROFILE" ]] && {
zshrc_start_time=$(date +%s.%N)
zmodload zsh/zprof
}
HISTFILE=~/.zhistory
HISTSIZE=10000
SAVEHIST=10000
@@ -159,7 +163,7 @@ bindkey '^r' history-incremental-search-backward
bindkey "^[[3~" delete-char
source_if_existing() {
if test -e "${1}" ; then source "${1}" ; else false ; fi
[[ -f "${1}" ]] && source "${1}"
}
source_first_existing() {
@@ -196,7 +200,20 @@ if [[ $- == *i* ]] ; then
zstyle ':compinstall' filename "${HOME}/.zshrc"
zstyle ':completion:*' users root ${USER}
# Modules after fpath
autoload -Uz compinit && compinit -i
autoload -Uz compinit
# Regenerate zcompdump if it's older than any file in fpath
DUMPFILE="${ZDOTDIR:-$HOME}/.zcompdump"
updated_files=(${^fpath}(N.om[1]))
if [[ ! -f "$DUMPFILE" || ( ${#updated_files} -gt 0 && "$updated_files[1]" -nt "$DUMPFILE" ) ]]; then
compinit -i -D "$DUMPFILE"
# Asynchronously compile the dump file
{ zcompile "$DUMPFILE" } &!
else
compinit -C -i -D "$DUMPFILE"
fi
unset DUMPFILE updated_files
autoload -Uz promptinit && promptinit
# Virtualenvwrapper
source_first_existing \
@@ -274,3 +291,11 @@ fi
# Cleanup PATH
typeset -U PATH
if [[ -n "$ZSH_PROFILE" ]]; then
zshrc_end_time=$(date +%s.%N)
elapsed_seconds=$(echo "$zshrc_end_time - $zshrc_start_time" | bc -l)
elapsed_ms=$(printf "%.0f" "$(echo "$elapsed_seconds * 1000" | bc -l)")
echo "zshrc done: ${elapsed_ms}ms"
zprof
fi

View File

@@ -0,0 +1,26 @@
#!/usr/bin/env zsh
# A function to run a command and send a notification when it's done.
# Usage: alert sleep 10
alert() {
# Run the command passed as arguments
"$@"
# Capture the exit code
local ret=$?
# Determine the icon based on success or failure
local icon
if [ $ret -eq 0 ]; then
icon="terminal"
else
icon="error"
fi
# Send the notification with the executed command
notify-send --urgency=low -i "$icon" "Finished: '$@'"
# Return the original exit code
return $ret
}

View File

@@ -15,3 +15,17 @@ if command -v ffuf >/dev/null 2>&1 ; then
alias ffuf-quick="ffuf -c -w $HOME/tools/seclists/Discovery/Web-Content/quickhits.txt"
fi
fi
if grep --help 2>/dev/null | grep -q 'color'; then
# Should have a better way to check for GNU versions
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
fi
# Detect which `ls` flavor is in use and use the right flag for colors.
if ls --help 2>&1 | grep -q -- '--color'; then
alias ls='ls --color=auto' # GNU `ls`
elif [ "$(uname)" = "Darwin" ]; then
alias ls='ls -G' # macOS `ls`
fi

View File

@@ -0,0 +1,9 @@
# Change to the root of the git repository.
# If not in a git repo, do nothing.
cdgr() {
local git_root
git_root=$(git rev-parse --show-toplevel 2>/dev/null)
if [ -n "$git_root" ]; then
cd "$git_root"
fi
}