dex icon indicating copy to clipboard operation
dex copied to clipboard

Add select command option -k to keep existing selections

Open olmokramer opened this issue 8 years ago • 3 comments

The current behavior of the select command is to call unselect when a selection already exists. This can be problematic in commands that convert selections to line selections. For example, the following script is supposed to prepend a // to each line in a selection, so it tries to convert regular selection into a line selection becaue otherwise the read command may not read the last line.

alias comment-lines \
  "select -l; filter $SHELL -c 'while read -r line; do printf \"//%s\n\" \"$line\"; done'

This PR adds an extra option to the select command, -k, that keeps existing selections.

olmokramer avatar Apr 25 '16 13:04 olmokramer

Is there a use case that can't be reasonably solved by just doing your selections with select -l in the first place?

craigbarnes avatar Jul 25 '17 07:07 craigbarnes

I can't reproduce any problems with this (assuming the line is closed with a double-quote). How can I reproduce it? Do you have a 'recipe' that reliably exhibits a problem??

pepa65 avatar Jul 26 '17 03:07 pepa65

This feature has been added to the dte fork in commit 73d0625c7

Your use case can be implemented as:

alias comment-lines "select -kl; filter sed 's|^|//|'"

craigbarnes avatar Jul 26 '17 04:07 craigbarnes