mirror of
https://github.com/keanuplayz/dotfiles.git
synced 2024-08-15 02:33:12 +00:00
add basic command palette widget
This commit is contained in:
parent
27d0185cf1
commit
c10ba15ff2
3 changed files with 27 additions and 3 deletions
|
@ -35,7 +35,7 @@ configure_oh_my_zsh() {
|
||||||
git
|
git
|
||||||
common-aliases
|
common-aliases
|
||||||
extract
|
extract
|
||||||
zsh-syntax-highlighting
|
# zsh-syntax-highlighting
|
||||||
)
|
)
|
||||||
|
|
||||||
if is_linux; then
|
if is_linux; then
|
||||||
|
|
23
widgets.zsh
Normal file
23
widgets.zsh
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
_command_palette_widgets=()
|
||||||
|
|
||||||
|
for widget_name widget_info in ${(kv)widgets}; do
|
||||||
|
[[ "$widget_name" == .* ]] && continue
|
||||||
|
[[ "$widget_info" == completion:* ]] && continue
|
||||||
|
_command_palette_widgets+=($widget_name)
|
||||||
|
done
|
||||||
|
|
||||||
|
_command-palette() {
|
||||||
|
local widget_name="$(echo "${(@j:\n:)_command_palette_widgets}" | peco)"
|
||||||
|
if [[ -n "$widget_name" ]]; then
|
||||||
|
python -c "
|
||||||
|
import fcntl, termios
|
||||||
|
with open('$TTY') as tty:
|
||||||
|
for char in '\x1bx$widget_name\n':
|
||||||
|
fcntl.ioctl(tty, termios.TIOCSTI, char)
|
||||||
|
"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
zle -N command-palette _command-palette
|
||||||
|
bindkey "^[P" command-palette
|
5
zshrc
5
zshrc
|
@ -14,10 +14,11 @@ find_dotfiles_dir() {
|
||||||
|
|
||||||
find_dotfiles_dir
|
find_dotfiles_dir
|
||||||
|
|
||||||
for script in "$DOTFILES_DIR"/{functions,path,exports,aliases,oh-my-zsh}.zsh; do
|
for script in functions path exports aliases oh-my-zsh widgets; do
|
||||||
source "$script"
|
source "${DOTFILES_DIR}/${script}.zsh"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
source_if_exists "$ZSH/custom/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh"
|
||||||
run_before rbenv 'eval "$(rbenv init -)"'
|
run_before rbenv 'eval "$(rbenv init -)"'
|
||||||
run_before sdk 'source_if_exists "$SDKMAN_DIR/bin/sdkman-init.sh"'
|
run_before sdk 'source_if_exists "$SDKMAN_DIR/bin/sdkman-init.sh"'
|
||||||
run_before yarn 'source_if_exists "$(yarn global dir)/node_modules/tabtab/.completions/yarn.zsh"'
|
run_before yarn 'source_if_exists "$(yarn global dir)/node_modules/tabtab/.completions/yarn.zsh"'
|
||||||
|
|
Loading…
Reference in a new issue