class Utils::ConfigFile::SshTunnel
environment variables, and managing copy/paste functionality for tunnel sessions.
specifications with local and remote address/port combinations, handling
different terminal multiplexers like tmux and screen. Allows setting up tunnel
Provides functionality for configuring and managing SSH tunnels with support for
SSH tunnel configuration manager
def copy_paste(enable = false, &block)
-
(CopyPaste, nil)
- the existing or newly created copy-paste
Other tags:
- Yield: - optional block to initialize the copy-paste instance
Parameters:
-
enable
(TrueClass, FalseClass
) -- flag to enable copy-paste functionality
def copy_paste(enable = false, &block) if @copy_paste @copy_paste else if block @copy_paste = CopyPaste.new(&block) elsif enable @copy_paste = CopyPaste.new {} end end end
def initialize
The initialize method sets up the instance by calling the superclass
def initialize super self.terminal_multiplexer = terminal_multiplexer end
def multiplexer_attach(session)
-
(String)
- a formatted command string ready for execution
Parameters:
-
session
(String
) -- the name or identifier of the session to attach to
def multiplexer_attach(session) case @multiplexer when 'screen' 'screen -DUR "%s"' % session when 'tmux' 'tmux -u attach -d -t "%s"' % session end end
def multiplexer_list
-
(String, nil)
- the command string to list sessions for the configured
def multiplexer_list case @multiplexer when 'screen' 'screen -ls' when 'tmux' 'tmux ls' end end
def multiplexer_new(session)
-
(String, nil)
- a command string for creating a new session in screen
Parameters:
-
session
(String
) -- the name of the session to be created
def multiplexer_new(session) case @multiplexer when 'screen' 'false' when 'tmux' 'tmux -u new -s "%s"' % session end end
def terminal_multiplexer=(terminal_multiplexer)
-
terminal_multiplexer
(Symbol
) -- the terminal multiplexer type to
def terminal_multiplexer=(terminal_multiplexer) @multiplexer = terminal_multiplexer.to_s @multiplexer =~ /\A(screen|tmux)\z/ or fail "invalid terminal_multiplexer #{terminal_multiplexer.inspect} was configured" end