Skip to content

Commit

Permalink
Convert the tmux utils to helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertAudi committed Mar 31, 2019
1 parent ca0c529 commit fb861c1
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/commands/restore.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function __tsm::commands::restore() {

while IFS=$'\t' read session_name window_name dir; do
if [[ -d "$dir" && "$window_name" != "log" && "$window_name" != "man" ]]; then
if __tsm::utils::session_exists "$session_name"; then
if __tsm::helpers::session_exists "$session_name"; then
__tsm::helpers::add_window "$session_name" "$window_name" "$dir"
else
__tsm::helpers::new_session "$session_name" "$window_name" "$dir" "$dimensions"
Expand Down
2 changes: 1 addition & 1 deletion src/commands/resume.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# 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 }
__tsm::commands::restore "$@" && { __tsm::helpers::inside_tmux || command tmux attach }
}
4 changes: 2 additions & 2 deletions src/utils/inside_tmux.zsh → src/helpers/inside_tmux.zsh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Check if tmux is running AND active
# (ie: we are inside a tmux session)
function __tsm::utils::inside_tmux() {
{ __tsm::utils::tmux_running && [[ -n "$TMUX" ]] } || return 1
function __tsm::helpers::inside_tmux() {
{ __tsm::helpers::tmux_running && [[ -n "$TMUX" ]] } || return 1
local -a tmux_info ; tmux_info=("${(s:,:)TMUX}")
[[ -S "${tmux_info[1]}" ]] && builtin kill -s 0 "${tmux_info[2]}" &>/dev/null
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Check if a tmux session exists.
function __tsm::utils::session_exists() {
function __tsm::helpers::session_exists() {
command tmux has-session -t "$1" 2>/dev/null
}
3 changes: 1 addition & 2 deletions src/utils/tmux_running.zsh → src/helpers/tmux_running.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# I am not a fan of the approach used
# but it will have to do until I find
# a better way of doing it.
function __tsm::utils::tmux_running() {
function __tsm::helpers::tmux_running() {
command tmux info &> /dev/null
}

0 comments on commit fb861c1

Please sign in to comment.