Skip to content

Commit

Permalink
Bugfix: sidebar size for tmux 2.1 and above
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno Sutic committed Oct 15, 2015
1 parent f1053da commit 2301452
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### master
- move customization options to a separate docs document
- sidebar size bugfix for tmux 2.1 and above

### v0.8.0, Apr 05, 2015
- do not colorize `tree` output because a pager application might not handle it
Expand Down
14 changes: 14 additions & 0 deletions scripts/helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,17 @@ width_from_sidebar_file() {
grep "^${pane_current_path}\t" $(sidebar_file) |
cut -f2
}

# function is used to get "clean" integer version number. Examples:
# `tmux 1.9` => `19`
# `1.9a` => `19`
_get_digits_from_string() {
local string="$1"
local only_digits="$(echo "$string" | tr -dC '[:digit:]')"
echo "$only_digits"
}

tmux_version_int() {
local tmux_version_string=$(tmux -V)
echo "$(_get_digits_from_string "$tmux_version_string")"
}
11 changes: 9 additions & 2 deletions scripts/toggle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,18 @@ desired_sidebar_size() {
fi
}

# tmux version 2.0 and below requires different argument for `join-pane`
use_inverted_size() {
[ tmux_version_int -le 20 ]
}

split_sidebar_left() {
local sidebar_size=$(desired_sidebar_size)
local inverted_size=$((PANE_WIDTH - $sidebar_size - 1))
if use_inverted_size; then
sidebar_size=$((PANE_WIDTH - $sidebar_size - 1))
fi
local sidebar_id="$(tmux new-window -c "$PANE_CURRENT_PATH" -P -F "#{pane_id}" "$COMMAND")"
tmux join-pane -hb -l "$inverted_size" -t "$PANE_ID" -s "$sidebar_id"
tmux join-pane -hb -l "$sidebar_size" -t "$PANE_ID" -s "$sidebar_id"
echo "$sidebar_id"
}

Expand Down

0 comments on commit 2301452

Please sign in to comment.