diff options
| author | Craig Jennings <c@cjennings.net> | 2026-01-26 17:36:38 -0600 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-01-26 17:36:38 -0600 |
| commit | dada2f255daaa2fb493ec8c7d47e2a8123aea494 (patch) | |
| tree | 0c0eeb84bb7b6e66a2d7f41cdfd061b25f80cc14 /dotfiles/common/.zshrc.d/fzf.sh | |
| parent | d50e5955837788fc69b4d5bc74cb574b859ed31a (diff) | |
refactor(dotfiles): rename system/ to common/ and remove unused configs
Rename dotfiles/system to dotfiles/common for clarity - indicates
shared dotfiles used across all desktop environments (DWM, Hyprland).
Removed config directories for uninstalled applications:
- ghostty (using different terminal)
- lf (using ranger instead)
- mopidy (using mpd instead)
- nitrogen (X11-only, obsolete for Wayland)
- pychess (not installed)
- JetBrains (not installed via archsetup)
- youtube-dl (using yt-dlp with different config location)
Kept audacious config for potential future use.
Updated all references in archsetup, CLAUDE.md, todo.org, and
validation.sh.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Diffstat (limited to 'dotfiles/common/.zshrc.d/fzf.sh')
| -rw-r--r-- | dotfiles/common/.zshrc.d/fzf.sh | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/dotfiles/common/.zshrc.d/fzf.sh b/dotfiles/common/.zshrc.d/fzf.sh new file mode 100644 index 0000000..9a5a9bd --- /dev/null +++ b/dotfiles/common/.zshrc.d/fzf.sh @@ -0,0 +1,122 @@ +# fzf.sh +# Craig Jennings <c@cjennings.net> +# FZF settings and utility functions + +# ============================================================================= +# Settings +# ============================================================================= +export FZF_DEFAULT_OPTS='--height=70%' +export FZF_DEFAULT_COMMAND='rg --files --no-ignore-vcs --hidden' +export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" + +# Directory paths for convenience functions +IF_GAMES_DIR="$HOME/sync/org/text.games" +BOOKS_DIR="$HOME/sync/books" + +# ============================================================================= +# Navigation +# ============================================================================= + +# cdff - change directory to where a file resides +cdff() { + file=$(fzf +m -q "$1") + dir=$(dirname "$file") + cd "$dir" || return 1 +} + +# cdd - cd to directory with fzf +cdd() { + destdir=$(find "${1:-.}" -path '*/\.*' -prune \ + -o -type d -print 2>/dev/null | fzf +m) && + cd "$destdir" +} + +# ============================================================================= +# System Admin +# ============================================================================= + +# Kill process with fzf +kp() { + pid=$(ps -ef | sed 1d | eval "fzf ${FZF_DEFAULT_OPTS} -m --header='[kill:process]'" | awk '{print $2}') + if [ -n "$pid" ]; then + echo "$pid" | xargs kill -"${1:-9}" + kp + fi +} + +# Install packages with fzf preview +yinstall() { + yay -Slq | fzf --multi --preview 'yay -Si {1}' | xargs -ro yay -S --noconfirm +} + +yinstall-skipverify() { + yay -Slq | fzf --multi --preview 'yay -Si {1}' | xargs -ro yay -S --noconfirm --mflags --skipinteg +} + +# Remove packages with fzf preview +yrm() { + yay -Qq | fzf --multi --preview 'yay -Qi {1}' | xargs -ro yay -Rns +} + +# Find in file with fzf +fif() { + if [ "$#" -eq 0 ]; then + echo "Need a string to search for!" + return 1 + fi + rg --files-with-matches --no-messages "$1" | \ + fzf --preview "highlight -O ansi -l {} 2>/dev/null | \ + rg --colors 'match:bg:yellow' --ignore-case --pretty --context 10 '$1' || \ + rg --ignore-case --pretty --context 10 '$1' {}" +} + +# ============================================================================= +# Convenience +# ============================================================================= + +# Find and read epub book in terminal +bk() { + bkfile=$(find "$BOOKS_DIR" -iname "*.epub" -print | fzf) + if [ -n "$bkfile" ]; then + epr "$bkfile" + fi +} + +# Find and play interactive fiction game +tg() { + gamefile=$(find "$IF_GAMES_DIR" -type f \( -iname "*.z[1-8]" -o -iname "*.zblorb" -o -iname "*.blorb" \) -print | fzf) + if [ -n "$gamefile" ]; then + frotz "$gamefile" + fi +} + +# ============================================================================= +# WireGuard +# ============================================================================= + +wgup() { + # Shutdown existing connections first + output=$(sudo wg 2>/dev/null) + if [ -n "$output" ]; then + for iface in $(sudo wg show interfaces); do + sudo wg-quick down "${iface}" + done + fi + # Select and start new connection + wgfile=$(sudo find /etc/wireguard/ -iname "*.conf" -exec basename -s .conf {} \; | fzf) + if [ -n "$wgfile" ]; then + sudo wg-quick up "$wgfile" + sudo wg + fi +} + +wgdown() { + output=$(sudo wg 2>/dev/null) + if [ -n "$output" ]; then + for iface in $(sudo wg show interfaces); do + sudo wg-quick down "${iface}" + done + fi +} + +alias wg=wgup |
