Allow using '$HOSTNAME' in @resurrect-dir

Closes #197
This commit is contained in:
Bruno Sutic 2017-06-01 17:18:39 +02:00
parent eef844c747
commit fbed36ad0e
No known key found for this signature in database
GPG Key ID: CAFA7B1B2914ED81
3 changed files with 14 additions and 1 deletions

View File

@ -19,6 +19,7 @@
- added guide for migrating from tmuxinator - added guide for migrating from tmuxinator
- fixed a bug for restoring commands on tmux 2.5 (and probably tmux 2.4) - fixed a bug for restoring commands on tmux 2.5 (and probably tmux 2.4)
- do not create another resurrect file if there are no changes (credit @vburdo) - do not create another resurrect file if there are no changes (credit @vburdo)
- allow using '$HOSTNAME' in @resurrect-dir
### v2.4.0, 2015-02-23 ### v2.4.0, 2015-02-23
- add "tmux-test" - add "tmux-test"

View File

@ -4,3 +4,12 @@ By default Tmux environment is saved to a file in `~/.tmux/resurrect` dir.
Change this with: Change this with:
set -g @resurrect-dir '/some/path' set -g @resurrect-dir '/some/path'
Using environment variables or shell interpolation in this option is not
allowed as the string is used literally. So the following won't do what is
expected:
set -g @resurrect-dir '/path/$MY_VAR/$(some_executable)'
Only the following variables and special chars are allowed:
`$HOME`, `$HOSTNAME`, and `~`.

View File

@ -98,11 +98,13 @@ pane_content_files_restore_from_archive() {
resurrect_dir() { resurrect_dir() {
if [ -z "$_RESURRECT_DIR" ]; then if [ -z "$_RESURRECT_DIR" ]; then
local path="$(get_tmux_option "$resurrect_dir_option" "$default_resurrect_dir")" local path="$(get_tmux_option "$resurrect_dir_option" "$default_resurrect_dir")"
echo "${path/#\~/$HOME}" # expands tilde if used with @resurrect-dir # expands tilde, $HOME and $HOSTNAME if used in @resurrect-dir
echo "$path" | sed "s,\$HOME,$HOME,g; s,\$HOSTNAME,$(hostname),g; s,\~,$HOME,g"
else else
echo "$_RESURRECT_DIR" echo "$_RESURRECT_DIR"
fi fi
} }
_RESURRECT_DIR="$(resurrect_dir)"
resurrect_file_path() { resurrect_file_path() {
if [ -z "$_RESURRECT_FILE_PATH" ]; then if [ -z "$_RESURRECT_FILE_PATH" ]; then
@ -112,6 +114,7 @@ resurrect_file_path() {
echo "$_RESURRECT_FILE_PATH" echo "$_RESURRECT_FILE_PATH"
fi fi
} }
_RESURRECT_FILE_PATH="$(resurrect_file_path)"
last_resurrect_file() { last_resurrect_file() {
echo "$(resurrect_dir)/last" echo "$(resurrect_dir)/last"