diff --git a/.tmux.conf b/.tmux.conf index 2aacde8..71109f7 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -56,6 +56,7 @@ bind-key / copy-mode \; send-key ? bind-key P 'capture-pane' \; capture-pane -S - \; save-buffer /tmp/tmux \; delete-buffer bind-key -n C-\\ copy-mode \; send -X search-backward " % "\; send -X search-again bind -n M-g display-popup -h '90%' -w '90%' -b rounded -d '#{pane_current_path}' -E "gitui" +bind -n M-e display-popup -h '60%' -w '80%' -b rounded -d '#{pane_current_path}' -E "~/bin/nvim-edit-fzf" setw -g window-status-format "" setw -g window-status-current-format "" diff --git a/.zshrc b/.zshrc index 8a4dd01..0c30ee2 100644 --- a/.zshrc +++ b/.zshrc @@ -104,6 +104,7 @@ export LESS="--mouse --wheel-lines=1 -nRXF" ## Aliases alias c='cut -c-${COLUMNS}' +alias e=nvim-edit-fzf alias dotgit='git --work-tree $HOME --git-dir $HOME/.dot_git' alias l=bat alias ls=exa @@ -139,20 +140,6 @@ set_win_title ## vim export EDITOR=nvim -e () -{ - if [ -n "$1" ]; then - _file=$(readlink -f "$@") - else - _git_root=$(git rev-parse --show-toplevel) - _store=$(printf $_git_root | sha1sum | cut -d ' ' -f 1) - _file=$( (fre --store_name $_store --sorted && fd --type f --hidden --follow --exclude .git . $_git_root) | fzf-tmux) - fre --store_name $_store --add $_file - fi - nvim --server $XDG_RUNTIME_DIR/nvim.sock --remote $_file - tmux select-window -t1 -} - ## fzf export FZF_TMUX=1 export FZF_COMPLETION_TRIGGER=";" diff --git a/bin/nvim-edit-fzf b/bin/nvim-edit-fzf new file mode 100755 index 0000000..5e87b3a --- /dev/null +++ b/bin/nvim-edit-fzf @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +set -fe -o pipefail + +if [ -n "$1" ]; then + _file=$(readlink -f "$@") +else + _git_root=$(git rev-parse --show-toplevel 2>/dev/null || pwd) + _store=$(echo "$_git_root" | sha1sum | cut -d ' ' -f 1) + _file=$( (fre --store_name "$_store" --sorted && fd --type f --hidden --follow --exclude .git . "$_git_root") | fzf ) + fre --store_name "$_store" --add "$_file" +fi + +nvim --server "$XDG_RUNTIME_DIR/nvim.sock" --remote "$_file" && tmux select-window -t1