Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Christian Salzmann-Jaeckel
tmux-resurrect
Commits
cfe8e797
Unverified
Commit
cfe8e797
authored
Aug 28, 2014
by
Bruno Sutic
Browse files
Restoring programs with arguments; improve process matching
Closes #20, closes #19
parent
093627ce
Changes
5
Hide whitespace changes
Inline
Side-by-side
CHANGELOG.md
View file @
cfe8e797
...
...
@@ -2,7 +2,9 @@
### master
-
bugfix: with vim 'session' strategy, if the session file does not exist - make
sure wim does not contain
`-S`
flag
sure vim does not contain
`-S`
flag
-
enable restoring programs with arguments (e.g. "rails console") and also
processes that contain program name
### v0.1.0, 2014-08-28
-
refactor checking if saved tmux session exists
...
...
README.md
View file @
cfe8e797
...
...
@@ -67,13 +67,21 @@ You should now be able to use the plugin.
### Configuration
Only a conservative list of programs is restored by default:
`vi vim emacs man less more tail top htop irssi irb pry`
.
`vi vim emacs man less more tail top htop irssi irb pry
"~rails console"
`
.
Open a github issue if you think some other program should be on the default list.
-
Restore additional programs
by putting the follow
ing in
`.tmux.conf`
:
-
Restore additional programs
with the sett
ing in
`.tmux.conf`
:
set -g @session-saver-processes 'ssh psql mysql sqlite3'
-
Programs with arguments should be double quoted:
set -g @session-saver-processes 'some_program "git log"'
-
Start with tilde to restore a program whose process contains target name:
set -g @session-saver-processes 'some_program "~rails server"'
-
Don't restore any programs:
set -g @session-saver-processes 'false'
...
...
scripts/helpers.sh
View file @
cfe8e797
...
...
@@ -46,6 +46,10 @@ supported_tmux_version_ok() {
$CURRENT_DIR
/check_tmux_version.sh
"
$SUPPORTED_VERSION
"
}
remove_first_char
()
{
echo
"
$1
"
|
cut
-c2-
}
# path helpers
sessions_dir
()
{
...
...
scripts/process_restore_helpers.sh
View file @
cfe8e797
# default processes that are restored
default_proc_list_option
=
"@session-saver-default-processes"
default_proc_list
=
"
vi vim emacs man less more tail top htop irssi irb pry
"
default_proc_list
=
'
vi vim emacs man less more tail top htop irssi irb pry
"~rails console"'
# User defined processes that are restored
# 'false' - nothing is restored
...
...
@@ -71,12 +71,21 @@ _restore_all_processes() {
_process_on_the_restore_list
()
{
local
pane_full_command
=
"
$1
"
local
restore_list
=
"
$(
_restore_list
)
"
# TODO: make this work without eval
eval set
$(
_restore_list
)
local
proc
for
proc
in
$restore_list
;
do
# regex matching the command makes sure process is a "word"
if
[[
"
$pane_full_command
"
=
~
(
^
${
proc
}
)
]]
||
[[
"
$pane_full_command
"
=
~
(
^
${
proc
}
$)
]]
;
then
return
0
for
proc
in
"
$@
"
;
do
if
_proc_starts_with_tildae
"
$proc
"
;
then
proc
=
"
$(
remove_first_char
"
$proc
"
)
"
# regex matching the command makes sure `$proc` string is somewhere the command string
if
[[
"
$pane_full_command
"
=
~
(
$proc
)
]]
;
then
return
0
fi
else
# regex matching the command makes sure process is a "word"
if
[[
"
$pane_full_command
"
=
~
(
^
${
proc
}
)
]]
||
[[
"
$pane_full_command
"
=
~
(
^
${
proc
}
$)
]]
;
then
return
0
fi
fi
done
return
1
...
...
@@ -93,6 +102,10 @@ _restore_list() {
fi
}
_proc_starts_with_tildae
()
{
[[
"
$1
"
=
~
(
^~
)
]]
}
_strategy_exists
()
{
local
pane_full_command
=
"
$1
"
local
strategy
=
"
$(
_get_command_strategy
"
$pane_full_command
"
)
"
...
...
scripts/session_restorer.sh
View file @
cfe8e797
...
...
@@ -41,10 +41,6 @@ tmux_socket() {
echo
$TMUX
|
cut
-d
','
-f1
}
remove_first_char
()
{
echo
"
$1
"
|
cut
-c2-
}
new_window
()
{
local
session_name
=
"
$1
"
local
window_number
=
"
$2
"
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment