summaryrefslogtreecommitdiff
path: root/.bashrc
diff options
context:
space:
mode:
authorMike Crute <mike@crute.us>2019-01-12 20:18:59 +0000
committerMike Crute <mike@crute.us>2019-01-12 20:18:59 +0000
commite79dd4edb30bb065279b475da6855343858b5adf (patch)
treed0930ada1471ebec3a875921b7146a2779eb5662 /.bashrc
parent4d4ffc2b77429c4af1836396d44ccd109a579178 (diff)
downloaddotfiles-e79dd4edb30bb065279b475da6855343858b5adf.tar.bz2
dotfiles-e79dd4edb30bb065279b475da6855343858b5adf.tar.xz
dotfiles-e79dd4edb30bb065279b475da6855343858b5adf.zip
Add option to not exec tmux
Diffstat (limited to '.bashrc')
-rw-r--r--.bashrc41
1 files changed, 37 insertions, 4 deletions
diff --git a/.bashrc b/.bashrc
index ee23800..8dd906e 100644
--- a/.bashrc
+++ b/.bashrc
@@ -369,6 +369,22 @@ function tmux_session_home
369function tm 369function tm
370{ 370{
371 local tmux="tmux -2" 371 local tmux="tmux -2"
372 local do_exec=1
373
374 local OPTIND opt
375 while getopts "nh" opt; do
376 case $opt in
377 n) # [n]o-exec
378 do_exec=0
379 ;;
380 h) # help
381 echo "Usage: tm [nh]"
382 echo " -n : Run but do not exec tmux"
383 echo " -h : Show this message"
384 return
385 ;;
386 esac
387 done
372 388
373 $tmux start-server 389 $tmux start-server
374 390
@@ -387,21 +403,38 @@ function tm
387 $tmux set-option -t "$1" -g status-bg colour234 403 $tmux set-option -t "$1" -g status-bg colour234
388 fi 404 fi
389 405
390 exec $tmux attach -t "$1" 406 if [[ $do_exec -eq 1 ]]; then
407 exec $tmux attach -t "$1"
408 else
409 $tmux attach -t "$1"
410 fi
391 return 411 return
392 fi 412 fi
393 413
394 if [[ $(type -t "tmux_session_$1") == "function" ]]; then 414 if [[ $(type -t "tmux_session_$1") == "function" ]]; then
395 $tmux new-session -d -s "$1" 415 $tmux new-session -d -s "$1"
396 eval "tmux_session_$1" "$1" 416 eval "tmux_session_$1" "$1"
397 exec $tmux attach-session -t "$1" 417
418 if [[ $do_exec -eq 1 ]]; then
419 exec $tmux attach-session -t "$1"
420 else
421 $tmux attach-session -t "$1"
422 fi
398 return 423 return
399 fi 424 fi
400 425
401 if (( $# == 2 )); then 426 if (( $# == 2 )); then
402 exec $tmux new -s "$1" -t "$2" 427 if [[ $do_exec -eq 1 ]]; then
428 exec $tmux new -s "$1" -t "$2"
429 else
430 $tmux new -s "$1" -t "$2"
431 fi
403 else 432 else
404 exec $tmux new -s "$1" 433 if [[ $do_exec -eq 1 ]]; then
434 exec $tmux new -s "$1"
435 else
436 $tmux new -s "$1"
437 fi
405 fi 438 fi
406} 439}
407func_export tm 440func_export tm