diff --git a/README.md b/README.md index 570889f..448108f 100644 --- a/README.md +++ b/README.md @@ -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. +* ``: toggle compact hints ( see [@fingers-compact-hints](#fingers-compact-hints) ). +* ``: 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: + +
+/path/to/foo/bar/lol
+
+with @fingers-compact-hints set to 1:
+
+awath/to/foo/bar/lol
+
+with @fingers-compact-hints set to 0:
+
+/path/to/foo/bar/lol [aw]
+
+ +( _pressing *aw* would yank `/path/to/foo/bar/lol`_ ) + +While in **[fingers]** mode you can press `` 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 ``. + # Acknowledgements and inspiration This plugin is heavily inspired by diff --git a/scripts/fingers.sh b/scripts/fingers.sh index 2616d50..1f382c9 100755 --- a/scripts/fingers.sh +++ b/scripts/fingers.sh @@ -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 diff --git a/scripts/hinter.awk b/scripts/hinter.awk index 7a7b144..30154a0 100644 --- a/scripts/hinter.awk +++ b/scripts/hinter.awk @@ -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); diff --git a/scripts/hints.sh b/scripts/hints.sh index 22a8d40..fb098ab 100755 --- a/scripts/hints.sh +++ b/scripts/hints.sh @@ -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() { diff --git a/scripts/tmux-fingers.sh b/scripts/tmux-fingers.sh index fb003cc..ce6976f 100755 --- a/scripts/tmux-fingers.sh +++ b/scripts/tmux-fingers.sh @@ -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 }