Skip to content

Commit

Permalink
automatic-rename: changelog and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno- committed Aug 30, 2021
1 parent 4234ba9 commit 6be2f34
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

### master
- Proper handling of `automatic-rename` window option.

### v3.0.0, 2021-08-30
- save and restore tmux pane contents (@laomaiweng)
Expand Down
6 changes: 5 additions & 1 deletion scripts/restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,13 @@ restore_window_properties() {
local window_name
\grep '^window' $(last_resurrect_file) |
while IFS=$d read line_type session_name window_number window_name window_active window_flags window_layout automatic_rename; do
tmux select-layout -t "${session_name}:${window_number}" "$window_layout"

# Below steps are properly handling window names and automatic-rename
# option. `rename-window` is an extra command in some scenarios, but we
# opted for always doing it to keep the code simple.
window_name="$(remove_first_char "$window_name")"
tmux rename-window -t "${session_name}:${window_number}" "$window_name"
tmux select-layout -t "${session_name}:${window_number}" "$window_layout"
if [ "${automatic_rename}" = ":" ]; then
tmux set-option -u -t "${session_name}:${window_number}" automatic-rename
else
Expand Down
2 changes: 1 addition & 1 deletion scripts/save.sh
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ dump_windows() {
continue
fi
automatic_rename="$(tmux show-window-options -vt "${session_name}:${window_index}" automatic-rename)"
# If the option was unset, place the ":" placeholder instead.
# If the option was unset, use ":" as a placeholder.
[ -z "${automatic_rename}" ] && automatic_rename=":"
echo "${line_type}${d}${session_name}${d}${window_index}${d}${window_name}${d}${window_active}${d}${window_flags}${d}${window_layout}${d}${automatic_rename}"
done
Expand Down

0 comments on commit 6be2f34

Please sign in to comment.