From d9265cbb18f2e478a67c9434b9569c9fa47ac707 Mon Sep 17 00:00:00 2001 From: Joachim Nielandt Date: Mon, 25 Oct 2021 19:51:11 +0200 Subject: [PATCH] Small change in settings. --- dot_Xresources.tmpl | 2 +- dot_fzf/shell/completion.zsh | 8 ++++---- dot_fzf/shell/key-bindings.zsh | 27 ++++++++++----------------- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/dot_Xresources.tmpl b/dot_Xresources.tmpl index c62fdcf..27689c0 100644 --- a/dot_Xresources.tmpl +++ b/dot_Xresources.tmpl @@ -26,7 +26,7 @@ URxvt*saveLines: 65500 URxvt*loginShell: false !URxvt*termName: screen-256color -{{- if eq .chezmoi.hostname "zaptorjezus" }} +{{- if (or (eq .chezmoi.hostname "zaptorjezus") (eq .chezmoi.hostname "zaptorjezus")) }} URxvt.font: xft:Fura Code Nerd Font Mono:size=10:antialias=true URxvt.boldfont: xft:Fura Code Nerd Font Mono:bold:size=10 {{- else }} diff --git a/dot_fzf/shell/completion.zsh b/dot_fzf/shell/completion.zsh index 2096ad4..f12afca 100644 --- a/dot_fzf/shell/completion.zsh +++ b/dot_fzf/shell/completion.zsh @@ -145,7 +145,7 @@ __fzf_generic_path_completion() { leftover=${leftover/#\/} [ -z "$dir" ] && dir='.' [ "$dir" != "/" ] && dir="${dir/%\//}" - matches=$(eval "$compgen $(printf %q "$dir")" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_COMPLETION_OPTS" __fzf_comprun "$cmd" ${(Q)${(Z+n+)fzf_opts}} -q "$leftover" | while read item; do + matches=$(eval "$compgen $(printf %q "$dir")" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore $FZF_DEFAULT_OPTS $FZF_COMPLETION_OPTS" __fzf_comprun "$cmd" ${(Q)${(Z+n+)fzf_opts}} -q "$leftover" | while read item; do echo -n "${(q)item}$suffix " done) matches=${matches% } @@ -207,11 +207,10 @@ _fzf_complete() { type $post > /dev/null 2>&1 || post=cat _fzf_feed_fifo "$fifo" - matches=$(FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_COMPLETION_OPTS $str_arg" __fzf_comprun "$cmd" "${args[@]}" -q "${(Q)prefix}" < "$fifo" | $post | tr '\n' ' ') + matches=$(FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore $FZF_DEFAULT_OPTS $FZF_COMPLETION_OPTS $str_arg" __fzf_comprun "$cmd" "${args[@]}" -q "${(Q)prefix}" < "$fifo" | $post | tr '\n' ' ') if [ -n "$matches" ]; then LBUFFER="$lbuf$matches" fi - zle reset-prompt command rm -f "$fifo" } @@ -225,7 +224,7 @@ _fzf_complete_telnet() { _fzf_complete_ssh() { _fzf_complete +m -- "$@" < <( setopt localoptions nonomatch - command cat <(cat ~/.ssh/config ~/.ssh/config.d/* /etc/ssh/ssh_config 2> /dev/null | command grep -i '^\s*host\(name\)\? ' | awk '{for (i = 2; i <= NF; i++) print $1 " " $i}' | command grep -v '[*?]') \ + command cat <(command tail -n +1 ~/.ssh/config ~/.ssh/config.d/* /etc/ssh/ssh_config 2> /dev/null | command grep -i '^\s*host\(name\)\? ' | awk '{for (i = 2; i <= NF; i++) print $1 " " $i}' | command grep -v '[*?]') \ <(command grep -oE '^[[a-z0-9.,:-]+' ~/.ssh/known_hosts | tr ',' '\n' | tr -d '[' | awk '{ print $1 " " $1 }') \ <(command grep -v '^\s*\(#\|$\)' /etc/hosts | command grep -Fv '0.0.0.0') | awk '{if (length($2) > 0) {print $2}}' | sort -u @@ -302,6 +301,7 @@ fzf-completion() { if eval "type _fzf_complete_${cmd} > /dev/null"; then prefix="$prefix" eval _fzf_complete_${cmd} ${(q)lbuf} + zle reset-prompt elif [ ${d_cmds[(i)$cmd]} -le ${#d_cmds} ]; then _fzf_dir_completion "$prefix" "$lbuf" else diff --git a/dot_fzf/shell/key-bindings.zsh b/dot_fzf/shell/key-bindings.zsh index 74ce9b7..8efa6af 100644 --- a/dot_fzf/shell/key-bindings.zsh +++ b/dot_fzf/shell/key-bindings.zsh @@ -45,7 +45,8 @@ __fsel() { -o -type d -print \ -o -type l -print 2> /dev/null | cut -b3-"}" setopt localoptions pipefail no_aliases 2> /dev/null - eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_CTRL_T_OPTS" $(__fzfcmd) -m "$@" | while read item; do + local item + eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore $FZF_DEFAULT_OPTS $FZF_CTRL_T_OPTS" $(__fzfcmd) -m "$@" | while read item; do echo -n "${(q)item} " done local ret=$? @@ -67,30 +68,22 @@ fzf-file-widget() { zle -N fzf-file-widget bindkey '^T' fzf-file-widget -# Ensure precmds are run after cd -fzf-redraw-prompt() { - local precmd - for precmd in $precmd_functions; do - $precmd - done - zle reset-prompt -} -zle -N fzf-redraw-prompt - # ALT-C - cd into the selected directory fzf-cd-widget() { local cmd="${FZF_ALT_C_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \ -o -type d -print 2> /dev/null | cut -b3-"}" setopt localoptions pipefail no_aliases 2> /dev/null - local dir="$(eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS" $(__fzfcmd) +m)" + local dir="$(eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS" $(__fzfcmd) +m)" if [[ -z "$dir" ]]; then zle redisplay return 0 fi - cd "$dir" - unset dir # ensure this doesn't end up appearing in prompt expansion + zle push-line # Clear buffer. Auto-restored on next prompt. + BUFFER="cd ${(q)dir}" + zle accept-line local ret=$? - zle fzf-redraw-prompt + unset dir # ensure this doesn't end up appearing in prompt expansion + zle reset-prompt return $ret } zle -N fzf-cd-widget @@ -100,8 +93,8 @@ bindkey '\ec' fzf-cd-widget fzf-history-widget() { local selected num setopt localoptions noglobsubst noposixbuiltins pipefail no_aliases 2> /dev/null - selected=( $(fc -rl 1 | perl -ne 'print if !$seen{(/^\s*[0-9]+\s+(.*)/, $1)}++' | - FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} $FZF_DEFAULT_OPTS -n2..,.. --tiebreak=index --bind=ctrl-r:toggle-sort $FZF_CTRL_R_OPTS --query=${(qqq)LBUFFER} +m" $(__fzfcmd)) ) + selected=( $(fc -rl 1 | perl -ne 'print if !$seen{(/^\s*[0-9]+\**\s+(.*)/, $1)}++' | + FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} $FZF_DEFAULT_OPTS -n2..,.. --tiebreak=index --bind=ctrl-r:toggle-sort,ctrl-z:ignore $FZF_CTRL_R_OPTS --query=${(qqq)LBUFFER} +m" $(__fzfcmd)) ) local ret=$? if [ -n "$selected" ]; then num=$selected[1]