Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow key binding to be customized via environment variable #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,23 @@ You can press:

# Configuration

- Edit `~/.tmux/tmux-picker/tmux-picker.tmux`, where you can change:
- `PICKER_KEY` (default <kbd>Meta</kbd> + <kbd>F</kbd>, without the prefix)
- `PATTERNS_LIST1` - regex patterns highlighted after pressing `PICKER_KEY`
- `PATTERNS_LIST2` - regex patterns highlighted after pressing <kbd>SPACE</kbd> in hint mode
- `BLACKLIST` - regex pattern describing items that will not be highlighted
- `PICKER_COPY_COMMAND` - command to execute on highlighted item
- default is: `xclip -f -in -sel primary | xclip -in -sel clipboard`, which copies item to clipboard
- `PICKER_COPY_COMMAND_UPPERCASE` - command to execute on highlighted item, when hint was typed using uppercase letters
- default is `bash -c 'arg=\$(cat -); tmux split-window -h -c \"#{pane_current_path}\" vim \"\$arg\"'`, which executes `vim` in a sidebar
- `PICKER_HINT_FORMAT` - describes hint color/style.
- Default is `#[fg=black,bg=red,bold]`, but `#[fg=color0,bg=color202,dim,bold]%s` is IMO better if your terminal supports 256 colors
- `PICKER_HIGHLIGHT_FORMAT` - describes highlighted item color/style
Select a custom key binding by setting the `PICKER_KEY` environment variable. For example to set change the binding to <kbd>F</kbd> with the prefix add this line to your `~/.tmux.conf`:

setenv -g PICKER_KEY 'F'

Or you can edit variables directly in the `~/.tmux/tmux-picker/tmux-picker.tmux` script. You can change:

- `PICKER_KEY` (default <kbd>Meta</kbd> + <kbd>F</kbd>, without the prefix)
- `PATTERNS_LIST1` - regex patterns highlighted after pressing `PICKER_KEY`
- `PATTERNS_LIST2` - regex patterns highlighted after pressing <kbd>SPACE</kbd> in hint mode
- `BLACKLIST` - regex pattern describing items that will not be highlighted
- `PICKER_COPY_COMMAND` - command to execute on highlighted item
- default is: `xclip -f -in -sel primary | xclip -in -sel clipboard`, which copies item to clipboard
- `PICKER_COPY_COMMAND_UPPERCASE` - command to execute on highlighted item, when hint was typed using uppercase letters
- default is `bash -c 'arg=\$(cat -); tmux split-window -h -c \"#{pane_current_path}\" vim \"\$arg\"'`, which executes `vim` in a sidebar
- `PICKER_HINT_FORMAT` - describes hint color/style.
- Default is `#[fg=black,bg=red,bold]`, but `#[fg=color0,bg=color202,dim,bold]%s` is IMO better if your terminal supports 256 colors
- `PICKER_HIGHLIGHT_FORMAT` - describes highlighted item color/style

# Requirements

Expand Down
2 changes: 1 addition & 1 deletion tmux-picker.tmux
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ BLACKLIST=(

# "-n M-f" for Alt-F without prefix
# "f" for prefix-F
PICKER_KEY="-n M-f"
PICKER_KEY="${PICKER_KEY:=-n M-f}"

set_tmux_env PICKER_PATTERNS1 $(array_join "|" "${PATTERNS_LIST1[@]}")
set_tmux_env PICKER_PATTERNS2 $(array_join "|" "${PATTERNS_LIST2[@]}")
Expand Down