Configurable tmux options

This commit is contained in:
Ferran Basora 2019-03-20 23:31:28 +00:00
parent 91cd2cc3d3
commit 14e8fa26e4
2 changed files with 203 additions and 65 deletions

224
README.md
View File

@ -59,71 +59,180 @@ tmux source-file ~/.tmux.conf
## Configuration ## Configuration
If you want to customize how is shown your tmux-thumbs hints you can run the If you want to customize how is shown your tmux-thumbs hints those all available
command `target/release/tmux-thumbs` directly and play with all available
parameters to set your perfect profile. parameters to set your perfect profile.
Once completed, write those parameters in NOTE: for changes to take effect, you'll need to source again your `.tmux.conf` file.
`~/.tmux/plugins/tmux-thumbs/tmux-thumbs.sh` file. There is a `COMMAND`
variable where you can set all those options.
Example: * [@thumbs-alphabet](#thumbs-alphabet)
* [@thumbs-reverse](#thumbs-reverse)
* [@thumbs-unique](#thumbs-unique)
* [@thumbs-position](#thumbs-position)
* [@thumbs-regexp-N](#thumbs-regexp-N)
* [@thumbs-command](#thumbs-command)
* [@thumbs-upcase-command](#thumbs-upcase-command)
* [@thumbs-bg-color](#thumbs-bg-color)
* [@thumbs-fg-color](#thumbs-fg-color)
* [@thumbs-hint-bg-color](#thumbs-hint-bg-color)
* [@thumbs-hint-fg-color](#thumbs-hint-fg-color)
* [@thumbs-select-fg-color](#thumbs-select-fg-color)
### @thumbs-alphabet
`default: qwerty`
Choose which set of characters is used to build hints. Review all [available alphabets](#Alphabets)
For example:
``` ```
./target/release/tmux-thumbs -a qwerty -r -u set -g @thumbs-alphabet dvorak-homerow
``` ```
You can review all available options executing: ### @thumbs-reverse
`default: disabled`
Choose in which direction you want to assign hints. Useful to get shorter hints closer to the cursor.
For example:
``` ```
> tmux-thumbs --help set -g @thumbs-reverse
tmux-thumbs 0.2.2
A lightning fast version of tmux-fingers, copy/pasting tmux like vimium/vimperator
USAGE:
tmux-thumbs [FLAGS] [OPTIONS]
FLAGS:
-h, --help Prints help information
-r, --reverse Reverse the order for assigned hints
-u, --unique Don't show duplicated hints for the same match
-V, --version Prints version information
OPTIONS:
-a, --alphabet <alphabet> Sets the alphabet [default: qwerty]
--bg-color <background_color> Sets the background color for matches [default: black]
--command <command> Pick command [default: tmux set-buffer {}]
--fg-color <foreground_color> Sets the foregroud color for matches [default: green]
--hint-bg-color <hint_background_color> Sets the background color for hints [default: black]
--hint-fg-color <hint_foreground_color> Sets the foregroud color for hints [default: yellow]
-p, --position <position> Hint position [default: left]
-x, --regexp <regexp>... Use this regexp as extra pattern to match
--select-fg-color <select_foreground_color> Sets the foregroud color for selection [default: blue]
--upcase-command <upcase_command> Upcase command [default: tmux paste-buffer]
``` ```
## Extra features ### @thumbs-unique
- **Arrow navigation:** You can use the arrows to move arround between all matched items. `default: disabled`
- **Auto paste:** If your last typed hint character is uppercase, you are going to pick and paste the desired hint.
### Arguments Choose if you want to assign the same hint for the same matched strings.
- **alphabet:** Choose which set of characters is used to build hints. Default [qwerty] For example:
- **reverse:** Choose in which direction you want to assign hints. Useful to get shorter hints closer.
- **unique:** Choose if you want to assign the same hint for the same matched strings.
- **position:** Choose where do you want to show the hint in the matched string. Options (left, right). Default [left]
- **regexp:** Add extra pattern to match. This paramenter can have multiple instances.
- **command:** Choose whish command execute when you press a hint
- **upcase-command:** Choose which command execute when you press a upcase hint
- **bg-color:** Sets the background color for matches [default: black] ```
- **fg-color:** Sets the foregroud color for matches [default: green] set -g @thumbs-unique
- **hint-bg-color:** Sets the background color for hints [default: black] ```
- **hint-fg-color:** Sets the foregroud color for hints [default: yellow]
- **select-fg-color:** Sets the foregroud color for selection [default: blue] ### @thumbs-position
`default: left`
Choose where do you want to show the hint in the matched string. Options (left, right).
For example:
```
set -g @thumbs-position right
```
### @thumbs-regexp-N
Add extra patterns to match. This paramenter can have multiple instances.
For example:
```
set @thumbs-regexp-1 '[a-z]+@[a-z]+.com' # Match emails
set @thumbs-regexp-2 '[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:' # Match MAC addresses
```
### @thumbs-command
`default: 'tmux set-buffer {}'`
Choose which command execute when you press a hint.
For example:
```
set -g @thumbs-command 'pbcopy'
```
### @thumbs-upcase-command
`default: 'tmux paste-buffer'`
Choose which command execute when you press a upcase hint
For example:
```
set -g @thumbs-upcase-command 'pbcopy'
```
### @thumbs-bg-color
`default: black`
Sets the background color for matches
For example:
```
set -g @thumbs-bg-color blue
```
### @thumbs-fg-color
`default: green`
Sets the foregroud color for matches
For example:
```
set -g @thumbs-fg-color green
```
### @thumbs-hint-bg-color
`default: black`
Sets the background color for hints
For example:
```
set -g @thumbs-hint-bg-color blue
```
### @thumbs-hint-fg-color
`default: yellow`
Sets the foregroud color for hints
For example:
```
set -g @thumbs-hint-fg-color green
```
### @thumbs-select-fg-color
`default: blue`
Sets the foregroud color for selection
For example:
```
set -g @thumbs-select-fg-color red
```
#### Colors
This is the list of available colors:
- black
- red
- green
- yellow
- blue
- magenta
- cyan
- white
- default
#### Alphabets #### Alphabets
@ -152,19 +261,10 @@ This is the list of available alphabets:
- `colemak-left-hand`: arstqwfpzxcv - `colemak-left-hand`: arstqwfpzxcv
- `colemak-right-hand`: neioluymjhk - `colemak-right-hand`: neioluymjhk
#### Colors ## Extra features
This is the list of available colors: - **Arrow navigation:** You can use the arrows to move arround between all matched items.
- **Auto paste:** If your last typed hint character is uppercase, you are going to pick and paste the desired hint.
- black
- red
- green
- yellow
- blue
- magenta
- cyan
- white
- default
## Background ## Background

View File

@ -2,13 +2,51 @@
source ~/.bash_profile source ~/.bash_profile
# Customize this command function boolean {
COMMAND="tmux-thumbs -a qwerty -r -u" VALUE=$(tmux show -v @thumbs-$1 2> /dev/null)
if [[ "${VALUE}" == "1" ]]; then
echo "--$1"
fi
}
function option {
VALUE=$(tmux show -v @thumbs-$1 2> /dev/null)
if [[ ${VALUE} ]]; then
echo "--$1 ${VALUE}"
fi
}
function multi {
VALUES=""
while read -r VALUE; do
VALUES="${VALUES} --$1 ${VALUE}"
done < <(tmux show 2> /dev/null | grep thumbs-$1- | cut -d' ' -f2 | sed s/\"//g)
echo ${VALUES}
}
PARAMS=()
PARAMS[0]=$(boolean reverse)
PARAMS[1]=$(boolean unique)
PARAMS[2]=$(option alphabet)
PARAMS[3]=$(option position)
PARAMS[4]=$(option fg-color)
PARAMS[5]=$(option bg-color)
PARAMS[6]=$(option hint-bg-color)
PARAMS[7]=$(option hint-fg-color)
PARAMS[8]=$(option select-fg-color)
PARAMS[9]=$(option command)
PARAMS[10]=$(option upcase-command)
PARAMS[11]=$(multi regexp)
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
TARGET_RELEASE="/target/release/" TARGET_RELEASE="/target/release/"
CURRENT_PANE_ID=$(tmux list-panes -F "#{pane_id}:#{?pane_active,active,nope}" | grep active | cut -d: -f1) CURRENT_PANE_ID=$(tmux list-panes -F "#{pane_id}:#{?pane_active,active,nope}" | grep active | cut -d: -f1)
NEW_ID=$(tmux new-window -P -d -n "[thumbs]" ${CURRENT_DIR}${TARGET_RELEASE}${COMMAND} --tmux-pane ${CURRENT_PANE_ID}) COMMAND="tmux-thumbs ${PARAMS[*]} --tmux-pane ${CURRENT_PANE_ID}"
NEW_ID=$(tmux new-window -P -d -n "[thumbs]" ${CURRENT_DIR}${TARGET_RELEASE}${COMMAND})
NEW_PANE_ID=$(tmux list-panes -a | grep ${NEW_ID} | grep --color=never -o '%[0-9]\+') NEW_PANE_ID=$(tmux list-panes -a | grep ${NEW_ID} | grep --color=never -o '%[0-9]\+')
tmux swap-pane -d -s ${CURRENT_PANE_ID} -t ${NEW_PANE_ID} tmux swap-pane -d -s ${CURRENT_PANE_ID} -t ${NEW_PANE_ID}