Class: Sshface::Setter
- Inherits:
-
Object
- Object
- Sshface::Setter
- Defined in:
- lib/sshface.rb
Overview
Your code goes here…
Instance Method Summary collapse
Instance Method Details
#face_list ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/sshface.rb', line 10 def face_list list = [] Dir.chdir("#{Etc.getpwuid.dir}/") do list = Dir.glob('.ssh-*').select { |f| File.directory? f } end list end |
#face_loop ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/sshface.rb', line 23 def face_loop face_hash = face_list.map.with_index{|e, index| [index, e]}.to_h face_hash.each do |k, v| puts "#{k}. #{v}" end puts "Select face number: " name = nil loop do name = gets.chomp.to_i break if face_hash.keys.include? name puts "Wrong choice" end puts "Selected: #{face_hash[name]}" set_face(face_hash[name]) puts "All set".colorize(:green) end |
#set_face(face) ⇒ Object
18 19 20 21 |
# File 'lib/sshface.rb', line 18 def set_face(face) `unlink ~/.ssh` `ln -s #{face} ~/.ssh` end |