mirror of
https://github.com/gotbletu/shownotes
synced 2024-11-15 00:12:53 +00:00
4.2 KiB
4.2 KiB
Tmux Run External Commands In Copy Mode
emulate right click "search google for {text}" like you do in GUI web browsers. We can do other custom commands also like search highlighted text in wikipedia, translate, text to speech and many others. Think of other stuff to use it with like mps-youtube, youtube-viewer, torrents ...etc. Share with me if you got some good ones =)
install requirements
tmux surfraw w3m translate-shell
configuration
vim ~/.tmux.conf
# tmux 2.4 or higher examples =====================
bind-key -T copy-mode-vi 'o' send-keys -X copy-selection \; new-window -n google \; send-keys -t google 'sr google "$(tmux show-buffer)" && tmux kill-window' 'Enter'
bind-key -T copy-mode-vi 'i' send-keys -X copy-selection \; new-window -n imagegoogle \; send-keys -t imagegoogle 'sr imagesgoogle "$(tmux show-buffer)" && tmux kill-window' 'Enter'
bind-key -T copy-mode-vi 'p' send-keys -X copy-selection \; new-window -n wikipedia \; send-keys -t wikipedia 'sr wikipedia "$(tmux show-buffer)" && tmux kill-window' 'Enter'
bind-key -T copy-mode-vi 'u' send-keys -X copy-selection \; new-window -n youtube \; send-keys -t youtube 'mpsyt /"$(tmux show-buffer)" && tmux kill-window' 'Enter'
bind-key -T copy-mode-vi 'O' send-keys -X copy-selection \; new-window -n w3m \; send-keys -t w3m 'w3m "$(tmux show-buffer)" && tmux kill-window' 'Enter'
# translate, dictionary, text to speech
bind-key -T copy-mode-vi 't' send-keys -X copy-selection \; new-window -n translate \; send-keys -t translate 'translate-shell es "$(tmux show-buffer)" | w3m && tmux kill-window' 'Enter'
bind-key -T copy-mode-vi 'd' send-keys -X copy-selection \; new-window -n dict \; send-keys -t dict 'translate-shell -d "$(tmux show-buffer)" | w3m && tmux kill-window' 'Enter'
bind-key -T copy-mode-vi 's' send-keys -X copy-selection \; new-window -n speak \; send-keys -t speak 'translate-shell -brief "$(tmux show-buffer)" -play && tmux kill-window' 'Enter'
# tmux 2.3 or lower examples ===================
bind-key -t vi-copy s copy-selection \; new-window -n gsearch \; send-keys -t gsearch 'sr google "$(tmux show-buffer)" && tmux kill-window' 'Enter'
bind-key -t vi-copy o copy-selection \; new-window -n google \; send-keys -t google 'sr -browser=elinks google "$(tmux show-buffer)" && tmux kill-window' 'Enter'
bind-key -t vi-copy i copy-selection \; new-window -n imagegoogle \; send-keys -t imagegoogle 'sr imagesgoogle "$(tmux show-buffer)" && tmux kill-window' 'Enter'
bind-key -t vi-copy p copy-selection \; new-window -n wikipedia \; send-keys -t wikipedia 'sr wikipedia "$(tmux show-buffer)" && tmux kill-window' 'Enter'
bind-key -t vi-copy t copy-selection \; new-window -n translate \; send-keys -t translate 'translate-shell es "$(tmux show-buffer)" | w3m && tmux kill-window' 'Enter'
bind-key -t vi-copy d copy-selection \; new-window -n dict \; send-keys -t dict 'translate-shell -d "$(tmux show-buffer)" | w3m && tmux kill-window' 'Enter'
bind-key -t vi-copy s copy-selection \; new-window -n speak \; send-keys -t speak 'translate-shell -brief "$(tmux show-buffer)" -play && tmux kill-window' 'Enter'
Usage
Enter into copy mode Prefix + ], then highlight the text you want, then hit the hotkey you binded in our configurations above
references
- https://www.youtube.com/watch?v=sYp2xfoq8Fs
- How To Use Surfraw
- How To Use W3M CLI Web Browser
- How To Use Tmux
contact
_ _ _ _
__ _ ___ | |_| |__ | | ___| |_ _ _
/ _` |/ _ \| __| '_ \| |/ _ \ __| | | |
| (_| | (_) | |_| |_) | | __/ |_| |_| |
\__, |\___/ \__|_.__/|_|\___|\__|\__,_|
|___/