class Pixiebox::Shell::StartupScript

Attributes

os[R]

Public Class Methods

get(os) click to toggle source
# File lib/pixiebox/shell/startup_script.rb, line 5
def get(os)
  case "#{os.user_shell}:#{os.to_s}"
  when /\/bin\/bash:darwin/, /\/bin\/bash:linux/
    Shell::Bash.new(os)
  when /\/bin\/zsh:darwin/, /\/bin\/zsh:linux/
    Shell::Zsh.new(os)
  else
    raise Errors::ShellNotSupported, "#{os.user_shell}:#{os.to_s}"
  end
end
new(os) click to toggle source
# File lib/pixiebox/shell/startup_script.rb, line 19
def initialize(os)
  @os = os
end

Public Instance Methods

filename() click to toggle source
# File lib/pixiebox/shell/startup_script.rb, line 43
def filename
  raise ::NotImplementedError, 'must have filename'
end
install_extensions() click to toggle source
# File lib/pixiebox/shell/startup_script.rb, line 23
def install_extensions
  source  = "#{os.extensions_dir}/extensions.bash"
  dest    = os.shell_extensions

  TTY::File.copy_file source, dest

  TTY::File.append_to_file(
    filename,
    "\n#{extension}\n"
    )
end
uninstall_extensions() click to toggle source
# File lib/pixiebox/shell/startup_script.rb, line 36
def uninstall_extensions
  TTY::File.gsub_file filename, /#{Regexp.escape(extension)}/ do
    "# pixiebox removed #{Time.now}"
  end
end

Private Instance Methods

extension() click to toggle source
# File lib/pixiebox/shell/startup_script.rb, line 48
def extension
  "# added by pixiebox\nsource #{os.shell_extensions}"
end