Skip to content

Commit

Permalink
Add the open command as an alias of the resume command
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertAudi committed Mar 26, 2017
1 parent 6ca77b1 commit fc61aa0
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 22 deletions.
38 changes: 27 additions & 11 deletions dist/bin/tsm
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,17 @@ readonly -l colors

local -A __tsm_commands
__tsm_commands=(
list "List saved sessions"
show "Show details about a session"
save "Save the current session"
remove "Remove a saved session"
rename "Rename a saved session"
copy "Copy a saved session"
restore "Restore a saved session"
resume "Restore and attach a saved session"
quit "Quit tmux"
version "Show version"
help "Show usage information"
list "List saved sessions"
show "Show details about a session"
save "Save the current session"
remove "Remove a saved session"
rename "Rename a saved session"
copy "Copy a saved session"
restore "Restore a saved session"
resume,open "Restore and attach a saved session"
quit "Quit tmux"
version "Show version"
help "Show usage information"
)
readonly -l __tsm_commands

Expand Down Expand Up @@ -595,6 +595,15 @@ Help-Message
function __tsm::commands::help::resume() {
cat <<Help-Message
Usage: tsm resume <name>
Aliased as: open
Help-Message
return 64
}

function __tsm::commands::help::open() {
cat <<Help-Message
Usage: tsm open <name>
Alias of: resume
Help-Message
return 64
}
Expand Down Expand Up @@ -656,6 +665,12 @@ function __tsm::commands::list() {
builtin print -- "\nNumber of saved sessions: $(__tsm::utils::colorize blue "${#session_files}")"
}

# Restore a session and attach to one
# Alias of: __tsm::commands::resume
function __tsm::commands::open() {
__tsm::commands::resume "$@"
}

# Create a backup of the current tmux session
# and then kill the tmux server
function __tsm::commands::quit() {
Expand Down Expand Up @@ -825,6 +840,7 @@ function __tsm::commands::restore() {
# -------------------------------------------------------------------------- }}}

# Restore a session and attach to one
# Also alias as: __tsm::commands::resume
# TODO: Specify which tmux session to attach to
function __tsm::commands::resume() {
__tsm::commands::restore "$@" && { __tsm::utils::inside_tmux || command tmux attach }
Expand Down
9 changes: 9 additions & 0 deletions src/commands/help.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ Help-Message
function __tsm::commands::help::resume() {
cat <<Help-Message
Usage: tsm resume <name>
Aliased as: open
Help-Message
return 64
}

function __tsm::commands::help::open() {
cat <<Help-Message
Usage: tsm open <name>
Alias of: resume
Help-Message
return 64
}
Expand Down
5 changes: 5 additions & 0 deletions src/commands/open.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Restore a session and attach to one
# Alias of: __tsm::commands::resume
function __tsm::commands::open() {
__tsm::commands::resume "$@"
}
1 change: 1 addition & 0 deletions src/commands/resume.zsh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Restore a session and attach to one
# Also alias as: __tsm::commands::resume
# TODO: Specify which tmux session to attach to
function __tsm::commands::resume() {
__tsm::commands::restore "$@" && { __tsm::utils::inside_tmux || command tmux attach }
Expand Down
22 changes: 11 additions & 11 deletions src/core/constants.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ readonly -l colors

local -A __tsm_commands
__tsm_commands=(
list "List saved sessions"
show "Show details about a session"
save "Save the current session"
remove "Remove a saved session"
rename "Rename a saved session"
copy "Copy a saved session"
restore "Restore a saved session"
resume "Restore and attach a saved session"
quit "Quit tmux"
version "Show version"
help "Show usage information"
list "List saved sessions"
show "Show details about a session"
save "Save the current session"
remove "Remove a saved session"
rename "Rename a saved session"
copy "Copy a saved session"
restore "Restore a saved session"
resume,open "Restore and attach a saved session"
quit "Quit tmux"
version "Show version"
help "Show usage information"
)
readonly -l __tsm_commands

Expand Down

0 comments on commit fc61aa0

Please sign in to comment.