Created
February 28, 2024 14:43
-
-
Save cherryramatisdev/b018014e0ffe4cea0eebb060f1188dee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
pbcopy | |
pane_count=$(tmux list-panes | wc -l) | |
edit() { | |
local current_pane="$(tmux list-panes -F "#{pane_active} #{pane_pid} #{pane_current_command}" | grep "^1" | awk '{print $3}')" | |
if [ "$current_pane" = "nvim" ] || [ "$current_pane" = "nvi" ] || [ "$current_pane" = "Vim" ] || [ "$current_pane" = "vim" ]; then | |
tmux send-keys ":e $(pbpaste)" Enter | |
else | |
tmux send-keys -X cancel | |
tmux send-keys "vi $(pbpaste)" Enter | |
fi | |
} | |
if [ "$pane_count" -gt 1 ] && tmux list-panes -F '#{pane_current_command}' | grep -q 'Vim\|vim\|nvi\|nvim\|neovim'; then | |
tmux select-pane -l | |
edit | |
else | |
edit | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Para usar no tmux:
bind-key -T copy-mode-vi C-f send-keys -X copy-pipe "tmux_open_selected_on_vim"