Compare commits

...

3 Commits

Author SHA1 Message Date
e9f9ce6193 Add .build-var zle widget
Press Ctrl-B to fuzzy find all configuration CMake variables for the
current build directory. Once a variable is selected, rewrite the
command-line to set the selected CMake variable.
2024-05-03 22:39:11 +01:00
766ac3c5bf Move fzf-history-search to utilities
Also rename to .fzf-history-search to avoid it turning up in normal
command completion as an option.
2024-05-03 22:38:19 +01:00
2d56207f1e Stop disabling Ex mode 2024-05-03 22:31:32 +01:00
3 changed files with 39 additions and 22 deletions

View File

@ -207,3 +207,23 @@ build-debug() {
local target=$1; shift 1
eval build $target && debug ~build/bin/$target "$@"
}
# Interactively view CMake variables
.build-var() {
if [[ ! -n $build_dir ]]; then
build-dir
fi
local var=$(
cat $build_dir/CMakeCache.txt |
grep --color=never -Ex '^\w+:\w+=.*$' |
fzf --layout=reverse --info=hidden --border=rounded \
--cycle --height=50%
)
if [[ -n "$var" ]]; then
BUFFER="cmake -B\$build_dir -D$var"
zle end-of-line
fi
zle reset-prompt
}
zle -N .build-var
bindkey '^B' .build-var

View File

@ -148,3 +148,22 @@ fi
ls-iommu() {
$HOME/.config/zsh/ls-iommu.sh | sort -n
}
# Fuzzy history search with fzf
function .fzf-history-search() {
local selected
selected=$(
cat $HISTFILE | # get entire history
sed 's/ *[0-9]* *//' | # remove cruft
awk '!seen[$0]++' | # remove duplicates
fzf --layout=reverse --tac --cycle --info=hidden \
--border=rounded --height=50%
)
if [[ -n "$selected" ]]; then
BUFFER="$selected"
zle end-of-line
fi
zle reset-prompt
}
zle -N .fzf-history-search
bindkey '^R' .fzf-history-search

22
zshrc
View File

@ -126,9 +126,6 @@ bindkey -M vicmd 'j' history-substring-search-down
bindkey -r '^[h'
bindkey -M vicmd 'K' run-help
# Disable Ex mode with ':'
bindkey -rM vicmd ':'
# Enable '<Shirt><Tab>' reverse order completions
bindkey '^[[Z' reverse-menu-complete
@ -146,25 +143,6 @@ if [[ `uname` = Linux ]]; then
[[ -n ${key[End]} ]] && bindkey "${key[End]}" end-of-line
fi
# Fuzzy history search with fzf
function fzf-history-search() {
local selected
selected=$(
cat $HISTFILE | # get entire history
sed 's/ *[0-9]* *//' | # remove cruft
awk '!seen[$0]++' | # remove duplicates
fzf --layout=reverse --tac --cycle --info=hidden \
--border=rounded --height=50%
)
if [[ -n "$selected" ]]; then
BUFFER="$selected"
zle end-of-line
fi
zle reset-prompt
}
zle -N fzf-history-search
bindkey '^R' fzf-history-search
# Enable changing cursor shape based on vi mode
if [ "$ITERM_PROFILE" != "" ] && [ "$TMUX" = "" ]; then
# iTerm2 cursor shape escape sequences outside tmux