Add session command
This commit is contained in:
		
							parent
							
								
									4ff10eb05e
								
							
						
					
					
						commit
						cc69638822
					
				
							
								
								
									
										26
									
								
								session/session.plugin.zsh
									
									
									
									
									
										Normal file
									
								
							
							
								
								
								
								
								
								
							
						
						
									
										26
									
								
								session/session.plugin.zsh
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,26 @@
 | 
			
		||||
session() {
 | 
			
		||||
  if [[ "$1" == "" ]]; then
 | 
			
		||||
    echo "usage: session <name> [<host>]"
 | 
			
		||||
  else
 | 
			
		||||
    local name=$1
 | 
			
		||||
    local host=$2
 | 
			
		||||
    if [[ "$3" != "" ]]; then
 | 
			
		||||
      echo "$fg[red]error:$reset_color invalid argument: $3"
 | 
			
		||||
      return 1
 | 
			
		||||
    fi
 | 
			
		||||
    if [[ "$TMUX" == "" ]]; then
 | 
			
		||||
      local cmd="tmux new-session -As $name"
 | 
			
		||||
      if [[ "$host" != "" ]]; then
 | 
			
		||||
        cmd="ssh $host -t $cmd"
 | 
			
		||||
      fi
 | 
			
		||||
      eval $cmd
 | 
			
		||||
    else
 | 
			
		||||
      if [[ "$host" != "" ]]; then
 | 
			
		||||
        echo "$fg[red]error:$reset_color <host> not allowed inside tmux session"
 | 
			
		||||
        return 1
 | 
			
		||||
      fi
 | 
			
		||||
      tmux new-session -Ads $name
 | 
			
		||||
      tmux switch-client -t $name
 | 
			
		||||
    fi
 | 
			
		||||
  fi
 | 
			
		||||
}
 | 
			
		||||
@ -62,6 +62,7 @@ notify_ignore_list=(
 | 
			
		||||
  ping
 | 
			
		||||
  podman
 | 
			
		||||
  python
 | 
			
		||||
  session
 | 
			
		||||
  slides
 | 
			
		||||
  ssh
 | 
			
		||||
  sudo
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										3
									
								
								zshrc
									
									
									
									
									
								
							
							
								
								
								
								
								
								
							
						
						
									
										3
									
								
								zshrc
									
									
									
									
									
								
							@ -41,6 +41,9 @@ source-plugin utilities
 | 
			
		||||
# Automatically source .enter and .exit scripts on cd
 | 
			
		||||
source-plugin autoenv
 | 
			
		||||
 | 
			
		||||
# Session manager
 | 
			
		||||
source-plugin session
 | 
			
		||||
 | 
			
		||||
# Layout tmux window commands
 | 
			
		||||
[ "$TMUX" != "" ] && source-plugin layout
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user