put list-sessions in a function and use it from both places
authorJoerg Jaspert <joerg@ganneff.de>
Tue, 16 Jul 2013 14:36:41 +0000 (16:36 +0200)
committerJoerg Jaspert <joerg@ganneff.de>
Tue, 16 Jul 2013 14:36:41 +0000 (16:36 +0200)
bin/tm

diff --git a/bin/tm b/bin/tm
index 311d728..01c8631 100755 (executable)
--- a/bin/tm
+++ b/bin/tm
@@ -206,19 +206,23 @@ function own_config() {
     fi
 }
 
+# Simple overview of running sessions
+function list_sessions() {
+    local IFS=""
+    if output=$(tmux list-sessions 2>/dev/null); then
+        echo $output
+    else
+        echo "No tmux sessions available"
+    fi
+}
+
 ########################################################################
 # MAIN work follows here
 
 # Check the first cmdline parameter, we might want to prepare something
 case ${cmdline} in
     ls)
-        # Simple overview of running sessions
-        IFS=""
-        if output=$(tmux list-sessions 2>/dev/null); then
-           echo $output
-        else
-            echo "No tmux sessions available"
-        fi
+        list_sessions
         exit 0
         ;;
     s|ms)
@@ -232,7 +236,7 @@ case ${cmdline} in
         while getopts "lnhs:m:c:e:" OPTION; do
             case $OPTION in
                 l) # ls
-                    tmux list-sessions
+                    list_sessions
                     exit 0
                     ;;
                 s) # ssh