wellle / tmux-complete.vim

Vim plugin for insert mode completion of words in adjacent tmux panes
MIT License
515 stars 21 forks source link

Add Feature: Copy all visible lines in specified tmux pane to buffer #96

Open Matt-A-Bennett opened 2 years ago

Matt-A-Bennett commented 2 years ago

This is my first pull request (following the new issue I created on 05/01/2022 requesting the feature), so I hope it's in good order. I explained the new feature in the updated README.md

At one point I accidentally overwrote the file sh/tmuxcomplete with an altered copy, so now it's showing that all the lines were changed. I actually only altered two functions and added a new option flag -t in the getopts loop. Below I just show the additional lines:

TARGET='-1'

while getopts enp:s:t:l:c:g: name
do case $name in

    t) TARGET="$OPTARG";;

    *) echo "Usage: $0 [-t <pane_index>] [-p pattern] [-s splitmode] [-l listargs] [-c captureargs] [-g grepargs]\n"
        exit 2;;
esac
done

and the two functions in they're entirety (the new part is the elif):

excludecurrent() {
    if [ "$EXCLUDE" = "1" ]; then
        currentpane=$(tmux display-message -p '11-#{session_id} ')
        # echo 1>&2 'current' "$currentpane"
        # use -F to match $ in session id
        grep -v -F "$currentpane"
    elif ! [ "$TARGET" = "-1" ]; then
        echo $(tmux display-message -p '01-#{session_id} ')$TARGET
    else
        cat
    fi
}

and (the new part is that uniq is changed to cat:

sortu() {
    if [ "$NOSORT" = "1" ]; then
        cat
    else
        sort -u
    fi
}

Please let me know if this feature is of interest/within the scope of the plugin, and if there's anymore I should do.