Compare commits

...

4 commits

Author SHA1 Message Date
odrling 5737760f84
[fish] remove outdated config
removed fzf/starship/direnv in other shells
2024-04-12 20:23:34 +02:00
odrling 31a0dc1ab3
delete fzf submodules 2024-04-12 20:21:41 +02:00
odrling 4fcbf4e8a2
[bash] fzy key bindings 2024-04-12 20:21:02 +02:00
odrling 7483c19218
[zsh] use fzy for completion 2024-04-12 19:35:17 +02:00
8 changed files with 106 additions and 20 deletions

@ -1 +0,0 @@
Subproject commit 3c0a6304756e890e0a605b742943a9bb8e1d2247

@ -1 +0,0 @@
Subproject commit 19776c420456c25ea3578aa7991e7fa41b0b4829

95
.bash/fzy.bash Normal file
View file

@ -0,0 +1,95 @@
# ____ ____
# / __/___ / __/
# / /_/_ / / /_
# / __/ / /_/ __/
# /_/ /___/_/ key-bindings.bash
#
# - $FZF_TMUX_OPTS
# - $FZF_CTRL_T_COMMAND
# - $FZF_CTRL_T_OPTS
# - $FZF_CTRL_R_OPTS
# - $FZF_ALT_C_COMMAND
# - $FZF_ALT_C_OPTS
[[ $- =~ i ]] || return 0
# Key bindings
# ------------
__fzf_select__() {
local cmd opts
cmd="${FZF_CTRL_T_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \
-o -type f -print \
-o -type d -print \
-o -type l -print 2> /dev/null | command cut -b3-"}"
opts="--height ${FZF_TMUX_HEIGHT:-40%} --bind=ctrl-z:ignore --reverse --scheme=path ${FZF_DEFAULT_OPTS-} ${FZF_CTRL_T_OPTS-} -m"
eval "$cmd" |
FZF_DEFAULT_OPTS="$opts" $(__fzfcmd) "$@" |
while read -r item; do
printf '%q ' "$item" # escape special chars
done
}
__fzfcmd() {
echo fzy
}
fzf-file-widget() {
local selected="$(__fzf_select__ "$@")"
READLINE_LINE="${READLINE_LINE:0:$READLINE_POINT}$selected${READLINE_LINE:$READLINE_POINT}"
READLINE_POINT=$(( READLINE_POINT + ${#selected} ))
}
__fzf_cd__() {
local cmd opts dir
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 | command cut -b3-"}"
opts="--height ${FZF_TMUX_HEIGHT:-40%} --bind=ctrl-z:ignore --reverse --scheme=path ${FZF_DEFAULT_OPTS-} ${FZF_ALT_C_OPTS-} +m"
dir=$(set +o pipefail; eval "$cmd" | FZF_DEFAULT_OPTS="$opts" $(__fzfcmd)) && printf 'builtin cd -- %q' "$dir"
}
__fzf_history__() {
local output
output=$(command fc -l -n -r 1 | sed 's/^[\t ]*//' | $(__fzfcmd) --query="$READLINE_LINE")
READLINE_LINE=${output#*$'\t'}
if [[ -z "$READLINE_POINT" ]]; then
echo "$READLINE_LINE"
else
READLINE_POINT=0x7fffffff
fi
}
# Required to refresh the prompt after fzf
bind -m emacs-standard '"\er": redraw-current-line'
bind -m vi-command '"\C-z": emacs-editing-mode'
bind -m vi-insert '"\C-z": emacs-editing-mode'
bind -m emacs-standard '"\C-z": vi-editing-mode'
if (( BASH_VERSINFO[0] < 4 )); then
# CTRL-T - Paste the selected file path into the command line
bind -m emacs-standard '"\C-t": " \C-b\C-k \C-u`__fzf_select__`\e\C-e\er\C-a\C-y\C-h\C-e\e \C-y\ey\C-x\C-x\C-f"'
bind -m vi-command '"\C-t": "\C-z\C-t\C-z"'
bind -m vi-insert '"\C-t": "\C-z\C-t\C-z"'
# CTRL-R - Paste the selected command from history into the command line
bind -m emacs-standard '"\C-r": "\C-e \C-u\C-y\ey\C-u`__fzf_history__`\e\C-e\er"'
bind -m vi-command '"\C-r": "\C-z\C-r\C-z"'
bind -m vi-insert '"\C-r": "\C-z\C-r\C-z"'
else
# CTRL-T - Paste the selected file path into the command line
bind -m emacs-standard -x '"\C-t": fzf-file-widget'
bind -m vi-command -x '"\C-t": fzf-file-widget'
bind -m vi-insert -x '"\C-t": fzf-file-widget'
# CTRL-R - Paste the selected command from history into the command line
bind -m emacs-standard -x '"\C-r": __fzf_history__'
bind -m vi-command -x '"\C-r": __fzf_history__'
bind -m vi-insert -x '"\C-r": __fzf_history__'
fi
# ALT-C - cd into the selected directory
bind -m emacs-standard '"\ec": " \C-b\C-k \C-u`__fzf_cd__`\e\C-e\er\C-m\C-y\C-h\e \C-y\ey\C-x\C-x\C-d"'
bind -m vi-command '"\ec": "\C-z\ec\C-z"'
bind -m vi-insert '"\ec": "\C-z\ec\C-z"'

View file

@ -36,10 +36,7 @@ export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
. ~/.bash/completions
# fzf
if command -v fzf 2>&1 > /dev/null; then
source ~/.bash/fzf/shell/key-bindings.bash
source ~/.bash/fzf/shell/completion.bash
fi
command -v fzy 2>&1 > /dev/null && source ~/.bash/fzy.bash
source ~/.bash/bash-preexec/bash-preexec.sh

View file

@ -17,10 +17,6 @@ if status is-interactive
update_cwd_osc # Run once since we might have inherited PWD from a parent shell
command -v fzf >/dev/null && source ~/.bash/fzf/shell/key-bindings.fish && fzf_key_bindings
command -v starship >/dev/null && starship init fish | source
command -v direnv >/dev/null && direnv hook fish | source
# fish overrides it at some point when used as a login shell (?)
export CDPATH="$ODRCDPATH"

9
.gitmodules vendored
View file

@ -23,12 +23,6 @@
[submodule ".local/share/fonts/dots"]
path = .local/share/fonts/dots
url = https://git.odrling.xyz/fonts
[submodule ".bash/fzf-tab-completion"]
path = .bash/fzf-tab-completion
url = https://github.com/lincheney/fzf-tab-completion.git
[submodule ".bash/fzf"]
path = .bash/fzf
url = https://github.com/junegunn/fzf.git
[submodule ".bash/bash-preexec"]
path = .bash/bash-preexec
url = https://github.com/rcaloras/bash-preexec.git
@ -47,3 +41,6 @@
[submodule ".config/mpv/submodules/mfcc64-scripts"]
path = .config/mpv/submodules/mfcc64-scripts
url = https://github.com/mfcc64/mpv-scripts.git
[submodule ".zsh/zsh-fzy"]
path = .zsh/zsh-fzy
url = https://github.com/aperezdc/zsh-fzy.git

1
.zsh/zsh-fzy Submodule

@ -0,0 +1 @@
Subproject commit 519327d9990fbea50f71649e378e650f594bb39b

10
.zshrc
View file

@ -12,10 +12,12 @@ source ~/.zsh/zsh-completions/zsh-completions.plugin.zsh
ZVM_INIT_MODE=sourcing
[ -z "$NVIM" ] && source ~/.zsh/zsh-vi-mode/zsh-vi-mode.plugin.zsh
if command -v fzf >/dev/null; then
source ~/.bash/fzf/shell/completion.zsh
source ~/.bash/fzf/shell/key-bindings.zsh
source ~/.bash/fzf-tab-completion/zsh/fzf-zsh-completion.sh
if command -v fzy >/dev/null; then
source ~/.zsh/zsh-fzy/zsh-fzy.plugin.zsh
bindkey '\ec' fzy-cd-widget
bindkey '^T' fzy-file-widget
bindkey '^R' fzy-history-widget
bindkey '^P' fzy-proc-widget
fi
source ~/.zsh/envs.zsh