Skip to content

Commit fd676d3

Browse files
committed
Merge branch 'VladimirPal-feature/orientation'
2 parents ab2e1ab + 5ae258b commit fd676d3

File tree

2 files changed

+34
-13
lines changed

2 files changed

+34
-13
lines changed

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,18 @@ $ tmux source-file ~/.tmux.conf
172172
If you want to open a playbook from a script you can use the `tome-open-playbook` command. It can be found where you installed the tmux plugin.
173173

174174
```
175-
Usage: tome-open-playbook [-s] [-l height]
175+
Usage: tome-open-playbook [-s] [-l size] [-H | -V]
176176
```
177177

178-
- `-s` will open a scratchpad
179-
- `-l` allows you to specify a height
178+
Uses the defaults set in tmux, you can override them with the options
180179

180+
- `-s` will open a scratchpad
181+
- `-l` allows you to specify a size in lines/columns or as a percentage (e.g. `8` or `50%`)
182+
- `-H` horizontal split
183+
- `-V` vertical split
181184

182185
## Configuration
183186

184-
185187
### Vim options
186188

187189
By default Tome has the following mappings:
@@ -194,7 +196,6 @@ xmap <Leader>p <Plug>(TomePlaySelection)
194196

195197
[See `help TomeConfig`](doc/tome.txt) in Vim to change them, and for more options.
196198

197-
198199
### tmux options
199200

200201
You can set any of these options by adding them to your `~/.tmux.conf` file:
@@ -203,14 +204,17 @@ You can set any of these options by adding them to your `~/.tmux.conf` file:
203204
set -g <option> "<value>"
204205
```
205206

206-
Where `<option>` and `<value>` correspond to one of the options specified below
207+
Where `<option>` and `<value>` correspond to one of the options specified below:
207208

208209
| Option | Default | Description |
209210
| :--- | :---: | :--- |
210211
| `@tome_key` | `p` | The key binding to open a Tome playbook. |
211212
| `@tome_scratch_key` | `P` | The key binding to open a Tome scratchpad. |
212-
| `@tome_height` | `8` | Height of the playbook vertial split. |
213+
| `@tome_split` | `vertical` | Split the window `vertical` panes stacked (top/bottom) or `horizontal` side by side (left/right). |
214+
| `@tome_size` | `8` or `50%`(h) | Size of the playbook split:<br>- `8` lines when vertical<br>- `50%` columns when horizontal. |
215+
| `@tome_height` | *(deprecated)* | Legacy option kept for backward compatibility. Prefer `@tome_size`. |
213216
| `@tome_editor` | detect (n)vim | Manually set your preferred editor. |
214217
| `@tome_playbook` | `.playbook.sh` | Name of the playbook to open. |
215218

216219

220+

tome-open-playbook

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,22 @@ get_option() {
55
echo "${res:-$2}"
66
}
77

8-
tome_height=$(get_option "@tome_height" 8)
8+
tome_split=$(get_option "@tome_split" vertical)
9+
# legacy option, only use if @tome_size is not defined
10+
tome_size=$(get_option "@tome_height" "")
11+
tome_size=$(get_option "@tome_size" "$tome_size")
912
tome_playbook=$(get_option "@tome_playbook" .playbook.sh)
1013
tome_editor=$(get_option "@tome_editor" -)
1114
scratchpad=0
1215

13-
while getopts 'sl:h' opt; do
16+
while getopts 'sl:HV' opt; do
1417
case "$opt" in
1518
s) scratchpad=1 ;;
16-
l) tome_height=$OPTARG ;;
19+
l) tome_size=$OPTARG ;;
20+
H) tome_split="horizontal" ;;
21+
V) tome_split="vertical" ;;
1722
*)
18-
echo "Usage: $(basename "$0") [-s] [-l height]"
23+
echo "Usage: $(basename "$0") [-s] [-l size] [-H | -V]"
1924
exit 1
2025
;;
2126
esac
@@ -33,10 +38,22 @@ if [ $tome_editor = '-' ]; then
3338
esac
3439
fi
3540

41+
if [ "$tome_split" = "horizontal" ]; then
42+
orient="-h"
43+
if [ -z "$tome_size" ]; then
44+
tome_size="50%"
45+
fi
46+
else
47+
orient="-v"
48+
if [ -z "$tome_size" ]; then
49+
tome_size="8"
50+
fi
51+
fi
52+
3653
if [ $scratchpad = 1 ]; then
3754
# open scratchpad
38-
tmux split-window -c '#{pane_current_path}' -vb -l "$tome_height" "$tome_editor -c TomeScratchPad"
55+
tmux split-window -c '#{pane_current_path}' $orient -b -l "$tome_size" "$tome_editor -c TomeScratchPad"
3956
else
4057
# open tome playbook
41-
tmux split-window -c '#{pane_current_path}' -vb -l "$tome_height" "$tome_editor -c TomePlayBook $tome_playbook"
58+
tmux split-window -c '#{pane_current_path}' $orient -b -l "$tome_size" "$tome_editor -c TomePlayBook $tome_playbook"
4259
fi

0 commit comments

Comments
 (0)