Module: CommandKit::Env::Shell
Overview
Methods related to the SHELL
environment variable.
Environment Variables
SHELL
- The current shell.
Instance Attribute Summary collapse
-
#shell ⇒ String?
readonly
The current shell.
-
#shell_type ⇒ :bash, ...
readonly
The current shell type.
Attributes included from CommandKit::Env
Instance Method Summary collapse
-
#initialize(**kwargs) ⇒ Object
Initialize #shell and #shell_type based on the
SHELL
environment variable.
Instance Attribute Details
#shell ⇒ String? (readonly)
The current shell.
22 23 24 |
# File 'lib/command_kit/env/shell.rb', line 22 def shell @shell end |
#shell_type ⇒ :bash, ... (readonly)
The current shell type.
27 28 29 |
# File 'lib/command_kit/env/shell.rb', line 27 def shell_type @shell_type end |
Instance Method Details
#initialize(**kwargs) ⇒ Object
Initialize #shell and #shell_type based on the SHELL
environment
variable.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/command_kit/env/shell.rb', line 38 def initialize(**kwargs) super(**kwargs) @shell = env['SHELL'] @shell_type = if @shell case File.basename(@shell) when /bash/ then :bash when /zsh/ then :zsh when /fish/ then :fish when /dash/ then :dash when /mksh/ then :mksh when /ksh/ then :ksh when /tcsh/ then :tcsh when /csh/ then :csh when /sh/ then :sh end end end |