aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeodarZ <neodarz@neodarz.net>2018-01-21 20:26:09 +0100
committerNeodarZ <neodarz@neodarz.net>2018-01-21 20:26:09 +0100
commitae30e8aba84ef9ff6f0a338e491a36af9cf31011 (patch)
tree09cd82e99e1038b4e64c86bec79ffccef0976864
parent514523d95d254f54f5dc446c520e967952127f79 (diff)
downloaddotfiles_ascii-ae30e8aba84ef9ff6f0a338e491a36af9cf31011.tar.xz
dotfiles_ascii-ae30e8aba84ef9ff6f0a338e491a36af9cf31011.zip
update tm script for a better
-rwxr-xr-xscripts/.scripts/tm.sh49
-rwxr-xr-xzsh/.zsh/aliases.zsh6
2 files changed, 50 insertions, 5 deletions
diff --git a/scripts/.scripts/tm.sh b/scripts/.scripts/tm.sh
new file mode 100755
index 0000000..851cd7e
--- /dev/null
+++ b/scripts/.scripts/tm.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+# source https://github.com/Drakirus/dotfiles/blob/master/bin/tm
+# abort if we're already inside a TMUX session
+if [ "$TMUX" != "" ]; then
+ echo "Already inside a TMUX session !!"
+ exit 1
+fi
+# startup a "default" session if non currently exists
+# tmux has-session -t _default || tmux new-session -s _default -d
+
+
+SessionNb=$( tmux list-sessions -F "#S" 2>/dev/null | wc -l )
+if [ $SessionNb -eq 0 ]; then
+ # read -p "Enter new session name: " SESSION_NAME
+ TERM=screen-256color-bce tmux new -s "Start" #"$SESSION_NAME"
+else
+ # present menu for user to choose which workspace to open
+ PS3="Please choose your session: "
+ options=($(tmux list-sessions -F "#S" 2>/dev/null) "New Session" "Independent attach")
+ echo "Available Options"
+ echo "------------------"
+ echo " "
+ select opt in "${options[@]}"
+ do
+ case $opt in
+ "New Session")
+ read -p "Enter new session name: " SESSION_NAME
+ TERM=screen-256color-bce tmux new -s "$SESSION_NAME"
+ break
+ ;;
+
+ "Independent attach")
+ optionsATTACH=($(tmux list-sessions -F "#S" 2>/dev/null))
+ echo " "
+ echo "Available sessions"
+ echo "------------------"
+ select optATT in "${optionsATTACH[@]}"
+ do
+ TERM=screen-256color-bce tmux new -s "Agent_infiltré" -t $optATT
+ exit 0
+ done
+ ;;
+ *)
+ TERM=screen-256color-bce tmux attach-session -t $opt
+ break
+ ;;
+ esac
+ done
+fi
diff --git a/zsh/.zsh/aliases.zsh b/zsh/.zsh/aliases.zsh
index d8c57c1..224f947 100755
--- a/zsh/.zsh/aliases.zsh
+++ b/zsh/.zsh/aliases.zsh
@@ -167,11 +167,7 @@ alias historyt="cat .zhistory | cut -d' ' -f2- | cut -d';' -f2- | awk '{CMD[\$1]
# mpc update
#}
-function tm() {
- X=$#
- [[ $X -eq 0 ]] || X=X
- tmux new-session -A -s $X
-}
+alias tm="~/.scripts/tm.sh"
function email() {
echo $3 | mutt -s $2 $1