diff --git a/README.md b/README.md index ffa0abc..3c8d5bd 100644 --- a/README.md +++ b/README.md @@ -222,6 +222,7 @@ Beyond standard shell and FZF bindings, these custom interactive shortcuts are a | `Ctrl+Alt+U` | Replace Command Token | Strips the first token (the command) from the current line. **If the line is empty**, it pulls the previous command and strips its first token, placing the cursor at the start for a quick replacement (e.g., changing `mkdir` to `cd` while keeping the paths). | | `Ctrl+Alt+=` | Inline Qalculate! Evaluation | Passes the current command-line buffer to `qalc` (Qalculate!) and prints the result, then clears the buffer. Allows rapid-fire math without leaving the shell — type `150 * 1.08`, press `Ctrl+Alt+=`, and see `162` immediately. | | `Ctrl+Enter` | Smart Execute | Context-aware Enter key. Empty buffer → standard Enter. Buffer ending with `=` → evaluates it as a math expression via `qalc` (same as `Ctrl+Alt+=`). Any other content → executes the command normally. | +| `@@` | FZF Inline Picker | Opens an interactive `fzf` session and injects the selected item directly at the cursor position in the current command line. Useful for inserting file paths, branch names, or any fzf-searchable content mid-command. | --- diff --git a/conf.d/key_bindings.fish b/conf.d/key_bindings.fish index 8b8dd06..109f3ca 100644 --- a/conf.d/key_bindings.fish +++ b/conf.d/key_bindings.fish @@ -54,6 +54,7 @@ function fish_user_key_bindings bind ctrl-alt-u _replace_command_token type -q qalc && bind ctrl-alt-= _qalc_eval bind ctrl-enter _smart_execute + bind @@ __fzf_inline_picker # Set bindings for all Vi modes: # 'default' is Vi-Command, 'insert' is Vi-Insert, 'visual' is Vi-Visual @@ -63,5 +64,6 @@ function fish_user_key_bindings bind --mode $mode ctrl-alt-u _replace_command_token type -q qalc && bind --mode $mode ctrl-alt-= _qalc_eval bind --mode $mode ctrl-enter _smart_execute + bind --mode $mode @@ __fzf_inline_picker end end diff --git a/config.fish b/config.fish index dafaf17..34bfff9 100644 --- a/config.fish +++ b/config.fish @@ -92,15 +92,16 @@ end # Adds common user bin directories to the PATH. The -mg --move option for cargo ensures that # the cargo bin directory is moved to the end of the PATH, which can help avoid conflicts # with system-installed Rust tools while still allowing user-installed cargo binaries to be found. -fish_add_path $HOME/.local/bin -fish_add_path $HOME/Applications -fish_add_path $HOME/scripts -fish_add_path -mg --move $CARGO_HOME/bin -fish_add_path $BUN_INSTALL/bin -fish_add_path $XDG_DATA_HOME/npm-global/bin -fish_add_path $HOME/.lmstudio/bin -fish_add_path $HOME/.resend/bin -fish_add_path $HOME/.fzf/bin +fish_add_path $HOME/.local/bin # Standard user-local executables (XDG spec) +fish_add_path $HOME/.local/share/../bin # Alternative/legacy path for local user binaries +fish_add_path $HOME/Applications # User-installed applications and standalone apps +fish_add_path $HOME/scripts # Custom personal shell scripts and automation +fish_add_path -mga $CARGO_HOME/bin # Rust binaries and tools installed via Cargo +fish_add_path $BUN_INSTALL/bin # Bun runtime executables and globally installed packages +fish_add_path $XDG_DATA_HOME/npm-global/bin # Global Node.js/npm packages (XDG compliant location) +fish_add_path $HOME/.lmstudio/bin # LM Studio CLI tools for local LLM management +fish_add_path $HOME/.resend/bin # Resend email service CLI tools +fish_add_path $HOME/.fzf/bin # Fuzzy Finder (fzf) core binary and helper scripts # ───────────────────────── CDPATH projects dir ────────────────────────── # Allows cd-ing to directories within $HOME/projects or $HOME without needing to specify the full path. diff --git a/functions/__fish_variable_check.fish b/functions/__fish_variable_check.fish new file mode 100644 index 0000000..0ec27fd --- /dev/null +++ b/functions/__fish_variable_check.fish @@ -0,0 +1,60 @@ +# Copyright (C) 2026 Rootiest +# SPDX-License-Identifier: AGPL-3.0-or-later + +# SYNOPSIS +# __fish_variable_check +# +# DESCRIPTION +# Evaluates a given variable's value to determine its truthiness or falsiness. +# It safely dereferences the variable name and performs case-insensitive matching. +# +# ARGUMENTS +# variable_name The name of the variable to check (e.g., __fish_config_strict_mode) +# Do NOT pass the value directly (do not use the $ prefix). +# +# RETURNS +# 0 True (Opt-In) : Matches 1, true, yes, on, y +# 1 False (Opt-Out) : Matches 0, false, no, off, n +# 2 Empty : Variable is unset or contains an empty string +# 3 Garbage : Variable contains an unrecognized value +# +# EXAMPLE +# __fish_variable_check __fish_config_strict_mode +# if test $status -eq 0 +# echo "Strict mode enabled!" +# end +# +function __fish_variable_check --description "Check if a variable is set to a truthy or falsy value." + set -l var_name $argv[1] + + # Make sure they actually passed an argument + if test -z "$var_name" + return 2 + end + + # 2: Empty / Unset (Check if the variable exists in the environment at all) + if not set -q $var_name + return 2 + end + + # Dereference the variable name to get its actual value using $$ + set -l val (string lower "$$var_name") + + # 2: Empty / Unset (Check if it exists but is just an empty string) + if test -z "$val" + return 2 + end + + # 0: True (Opt-In) + if contains -- "$val" 1 true yes on y + return 0 + end + + # 1: False (Opt-Out) + if contains -- "$val" 0 false no off n + return 1 + end + + # 3: Garbage / Unrecognized + return 3 +end diff --git a/functions/__fzf_inline_picker.fish b/functions/__fzf_inline_picker.fish new file mode 100644 index 0000000..3485b0b --- /dev/null +++ b/functions/__fzf_inline_picker.fish @@ -0,0 +1,29 @@ +# Copyright (C) 2026 Rootiest +# SPDX-License-Identifier: AGPL-3.0-or-later + +# SYNOPSIS +# __fzf_inline_picker +# +# DESCRIPTION +# Opens an interactive fzf session and injects the selected item directly +# into the command line at the cursor position. Bound to @@ by default. +# Requires fzf to be installed. Repaints the prompt after insertion. +# +# RETURNS +# 0 A selection was made and inserted into the command line +# 0 No selection was made (fzf cancelled); command line is unchanged +# +# EXAMPLE +# # Press @@ at the prompt — fzf opens, pick an item, it appears at cursor +# +function __fzf_inline_picker + # Open fzf and capture selection + set -l selection (fzf) + + if test -n "$selection" + # Injects text instantly at the cursor + commandline -i (string escape -- $selection) + end + # Refresh the line display + commandline -f repaint +end