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.
This commit is contained in:
parent
766ac3c5bf
commit
dcacb1de42
@ -207,3 +207,23 @@ build-debug() {
|
|||||||
local target=$1; shift 1
|
local target=$1; shift 1
|
||||||
eval build $target && debug ~build/bin/$target "$@"
|
eval build $target && debug ~build/bin/$target "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Fuzzy find CMake variables, select one to set the variable via a command.
|
||||||
|
.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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user