Class: Tmuxification::App

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/tmuxification.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#project_nameObject (readonly)

Returns the value of attribute project_name.



7
8
9
# File 'lib/tmuxification.rb', line 7

def project_name
  @project_name
end

#project_rootObject (readonly)

Returns the value of attribute project_root.



7
8
9
# File 'lib/tmuxification.rb', line 7

def project_root
  @project_root
end

#template_nameObject (readonly)

Returns the value of attribute template_name.



7
8
9
# File 'lib/tmuxification.rb', line 7

def template_name
  @template_name
end

Class Method Details

.source_rootObject

source root for templates etc.



50
51
52
# File 'lib/tmuxification.rb', line 50

def self.source_root
  File.dirname(__FILE__) + '/..'
end

Instance Method Details

#createObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/tmuxification.rb', line 11

def create
  setup
  @project_name = options.fetch('project_name') { Dir.pwd.split('/').last }
  @project_root = Dir.pwd
  @template_name = options.fetch('template_name') { "default.#{current_shell}" }

  template template_file, project_file
  chmod project_file, 777 # ha!
  append_to_file shellrc_file, "#{shell_source_command} #{project_file}\n"
end

#destroy(project_name = nil) ⇒ Object



23
24
25
26
# File 'lib/tmuxification.rb', line 23

def destroy(project_name = nil)
  @project_name ||= Dir.pwd.split('/').last
  File.delete project_file if File.exists?(project_file)
end

#listObject



29
30
31
32
33
# File 'lib/tmuxification.rb', line 29

def list
  Dir.glob(config_directory + '/*.tmux').map { |path| path.split('/').last }.each do |project_name|
    puts project_name
  end
end

#setupObject



36
37
38
39
40
41
42
# File 'lib/tmuxification.rb', line 36

def setup
  empty_directory config_directory
  @template_name = 'default.zsh'
  copy_file 'templates/default.zsh.tmux.erb', template_file unless File.exists?(template_file)
  @template_name = 'default.fish'
  copy_file 'templates/default.fish.tmux.erb', template_file unless File.exists?(template_file)
end

#teardownObject



45
46
47
# File 'lib/tmuxification.rb', line 45

def teardown
  Dir.rmdir(config_directory) if yes? 'Are you sure?'
end