updating README.md

This commit is contained in:
Jorge Morante 2016-10-17 21:44:28 +02:00
parent d257428cea
commit c5353288f1
5 changed files with 56 additions and 17 deletions

View File

@ -8,7 +8,7 @@
# Usage
When called ( `prefix + F` ), it will highlight relevant stuff in the current
Press ( `prefix + F` ) to enter **[fingers]** mode, it will highlight relevant stuff in the current
pane along with letter hints. By pressing those letters, the highlighted match
will be yanked. Less keystrokes == profit!
@ -27,6 +27,15 @@ Additionally, you can install
[tmux-yank](https://github.com/tmux-plugins/tmux-yank) for system clipboard
integration.
## Key shortcuts
While the in **[fingers]** mode, you can use the following shortcuts:
* `a-z`: yank a highlighted hint.
* `<space>`: toggle compact hints ( see [@fingers-compact-hints](#fingers-compact-hints) ).
* `<Ctrl-C>`: exit **[fingers]** mode
* `?`: show help.
# Requirements
* bash 4+
@ -72,7 +81,9 @@ You can change the key that invokes **tmux-fingers**:
## @fingers-key
F is the default key, but you can set another one.
`default: F`
Customize how to enter copy mode. Always preceded by prefix: `prefix + @fingers-key`
```
set -g @fingers-key F
@ -112,6 +123,35 @@ If you still want to set your own custom command you can do so like this:
set -g @fingers-copy-command 'xclip -selection clipboard'
```
## @fingers-compact-hints
`default: 1`
By default **tmux-fingers** will show hints a compact format. For example:
<pre>
/path/to/foo/bar/lol
<i>with <bold>@fingers-compact-hints</bold> set to <bold>1</bold>:</i>
<strong>aw</strong>ath/to/foo/bar/lol
<i>with <bold>@fingers-compact-hints</bold> set to <bold>0</bold>:</i>
/path/to/foo/bar/lol <strong>[aw]</strong>
</pre>
( _pressing *aw* would yank `/path/to/foo/bar/lol`_ )
While in **[fingers]** mode you can press `<space>` to toggle compact mode on/off.
Compact mode is preferred because it preserves the length of lines and doesn't
cause line wraps, making it easier to follow.
However for small hints this can be troublesome: a path as small as `/a/b`
would have half of its original content concealed. If that's the case you can
quickly toggle off compact mode by pressing `<space>`.
# Acknowledgements and inspiration
This plugin is heavily inspired by

View File

@ -83,13 +83,13 @@ show_hints_and_swap $current_pane_id $fingers_pane_id
hide_cursor
input=''
collapsed_state=1
compact_state=1
function toggle_collapsed_state() {
if [[ $collapsed_state == "0" ]]; then
collapsed_state=1
function toggle_compact_state() {
if [[ $compact_state == "0" ]]; then
compact_state=1
else
collapsed_state=0
compact_state=0
fi
}
@ -109,13 +109,12 @@ while read -rsn1 char; do
continue
fi
if [[ $char == "$BACKSPACE" ]]; then
input=""
continue
elif [[ $char == "" ]]; then
toggle_collapsed_state
show_hints "$fingers_pane_id" $collapsed_state
toggle_compact_state
show_hints "$fingers_pane_id" $compact_state
else
input="$input$char"
fi

View File

@ -2,7 +2,7 @@ BEGIN {
n_matches = 0;
line_pos = 0;
col_pos = 0;
COLLAPSE_HINTS = ENVIRON["COLLAPSED_HINTS"];
COMPACT_HINTS = ENVIRON["COMPACT_HINTS"];
HINTS[0] = "p"
HINTS[1] = "o"
@ -107,7 +107,7 @@ BEGIN {
finger_patterns = ENVIRON["FINGER_PATTERNS"];
if (COLLAPSE_HINTS) {
if (COMPACT_HINTS) {
hint_format = "\033[30;1;43m%s\033[0m"
highlight_format = "\033[1;33m%s\033[0m"
compound_format = hint_format highlight_format
@ -139,7 +139,7 @@ BEGIN {
line_match = substr(line, RSTART, RLENGTH);
full_line_match = line_match
if (COLLAPSE_HINTS) {
if (COMPACT_HINTS) {
hint_len = length(hint)
line_match = substr(line_match, hint_len + 1, length(line_match) - hint_len);
}
@ -150,7 +150,7 @@ BEGIN {
pre_match = substr(output_line, 0, col_pos - 1);
if (COLLAPSE_HINTS) {
if (COMPACT_HINTS) {
hint_match = sprintf(compound_format, hint, line_match);
} else {
hint_match = sprintf(compound_format, line_match, hint);

View File

@ -30,10 +30,10 @@ function get_stdin() {
function show_hints() {
local fingers_pane_id=$1
local collapsed_hints=$2
local compact_hints=$2
clear_screen "$fingers_pane_id"
get_stdin | COLLAPSED_HINTS=$collapsed_hints FINGER_PATTERNS=$PATTERNS __awk__ -f $CURRENT_DIR/hinter.awk 3> $match_lookup_table
get_stdin | COMPACT_HINTS=$compact_hints FINGER_PATTERNS=$PATTERNS __awk__ -f $CURRENT_DIR/hinter.awk 3> $match_lookup_table
}
function show_hints_and_swap() {

View File

@ -4,7 +4,7 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $CURRENT_DIR/utils.sh
function init_fingers_pane() {
local pane_id=$(tmux new-window -F "#{pane_id}" -P -d -n "!fingers")
local pane_id=$(tmux new-window -F "#{pane_id}" -P -d -n "[fingers]")
echo $pane_id
}