File tree Expand file tree Collapse file tree 4 files changed +20
-1
lines changed Expand file tree Collapse file tree 4 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 77- fix bug when yank-line is used in the last line in buffer. New 'solution' is
88 implemented for copying multiple lines.
99- code cleanup
10+ - yank-line never yanks 'newline' char for multiple-line commands in shell (this
11+ is actually tmux/bash bug).
1012
1113### v0.0.2, Jun 25, 2014
1214
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ end_of_line_in_copy_mode() {
6363}
6464
6565yank_to_clipboard () {
66- tmux send-key " $( yank_key ) "
66+ tmux send-key " $( yank_wo_newline_key ) "
6767}
6868
6969go_to_the_end_of_current_line () {
Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ put_option="@copy_mode_put"
1010yank_put_default=" M-y"
1111yank_put_option=" @copy_mode_yank_put"
1212
13+ yank_wo_newline_default=" !"
14+ yank_wo_newline_option=" @copy_mode_yank_wo_newline"
15+
1316# helper functions
1417get_tmux_option () {
1518 local option=" $1 "
@@ -38,6 +41,10 @@ yank_put_key() {
3841 echo " $( get_tmux_option " $yank_put_option " " $yank_put_default " ) "
3942}
4043
44+ yank_wo_newline_key () {
45+ echo " $( get_tmux_option " $yank_wo_newline_option " " $yank_wo_newline_default " ) "
46+ }
47+
4148# Ensures a message is displayed for 5 seconds in tmux prompt.
4249# Does not override the 'display-time' tmux option.
4350display_message () {
Original file line number Diff line number Diff line change @@ -18,6 +18,11 @@ clipboard_copy_command() {
1818 fi
1919}
2020
21+ clipboard_copy_without_newline_command () {
22+ local copy_command=" $1 "
23+ echo " tr -d '\n' | $copy_command "
24+ }
25+
2126set_error_bindings () {
2227 local key_bindings=" $( yank_key) $( put_key) $( yank_put_key) "
2328 local key
@@ -35,15 +40,20 @@ error_handling_if_command_not_present() {
3540 fi
3641}
3742
43+ # `yank_without_newline` binding isn't intended to be used by the user. It is
44+ # a helper for `copy_line` command.
3845set_copy_mode_bindings () {
3946 local copy_command=" $1 "
47+ local copy_wo_newline_command=" $( clipboard_copy_without_newline_command " $copy_command " ) "
4048 tmux bind-key -t vi-copy " $( yank_key) " copy-pipe " $copy_command "
4149 tmux bind-key -t vi-copy " $( put_key) " copy-pipe " tmux paste-buffer"
4250 tmux bind-key -t vi-copy " $( yank_put_key) " copy-pipe " $copy_command ; tmux paste-buffer"
51+ tmux bind-key -t vi-copy " $( yank_wo_newline_key) " copy-pipe " $copy_wo_newline_command "
4352
4453 tmux bind-key -t emacs-copy " $( yank_key) " copy-pipe " $copy_command "
4554 tmux bind-key -t emacs-copy " $( put_key) " copy-pipe " tmux paste-buffer"
4655 tmux bind-key -t emacs-copy " $( yank_put_key) " copy-pipe " $copy_command ; tmux paste-buffer"
56+ tmux bind-key -t emacs-copy " $( yank_wo_newline_key) " copy-pipe " $copy_wo_newline_command "
4757}
4858
4959set_copy_line_bindings () {
You can’t perform that action at this time.
0 commit comments