OSX

Using Vi with Bash and Readline Applications

June 15th, 2009 0 Comments

This weekend I came across a couple posts on Daily Vim about using vi in other applications such as bash, irb, mysql, or any other readline application.

To use vi mode for all readline applications, including bash, put the following line in your ~/.inputrc file.

set editing-mode vi

To use vi mode for bash only, put the following line in your ~/.bash_profile.

set -o vi

With these features enable, you’re dropped into insert mode and from there you can hit Esc or Ctrl-[ to change to command mode.  Enjoy.

Syncing Your SSH Keys with Ruby

June 4th, 2008 0 Comments
 1 #!/usr/bin/env ruby
 2 
 3 def sync_ssh_key
 4 
 5   # Default servers
 6   servers = ['my.server.com']
 7 
 8   # Use passed in list of servers.
 9   servers = $* unless $*.empty?
10 
11   servers.each do |server|
12     puts "---------------#{server}----------------"
13 
14     puts "Touching .ssh/authorized_keys on #{server}"
15     next unless system("ssh #{server} \"mkdir -p .ssh; touch .ssh/authorized_keys; touch .ssh/authorized_keys2\" ")
16 
17     puts "Copying public key to #{server}"
18     next unless system("scp ~/.ssh/id_rsa.pub #{server}:.ssh/authorized_keys")
19     next unless system("scp ~/.ssh/id_rsa.pub #{server}:.ssh/authorized_keys2")
20 
21     puts 'Setting public key permissions'
22     next unless system("ssh #{server} \"chmod 700 .ssh; chmod 600 .ssh/authorized_keys; chmod 600 .ssh/authorized_keys2\"")
23   end
24 
25 end
26 
27 
28 sync_ssh_key if __FILE__ == $0