Showing posts with label tools. Show all posts
Showing posts with label tools. Show all posts

7.21.2017

Mac Cheat Sheet

1. Install sshpass
$ brew install http://git.io/sshpass.rb

2. Using iTerm2, configure profiles and use sshpass so there's no need to enter passwords for ssh, follow this post for configuring iTerm2. What worked for me is in Command, select "Login shell", then send text at start:
sshpass -p 'password' ssh -o StrictHostKeyChecking=no user@server


1.06.2015

p4 diff output colorizer

Create a ruby file p4c.rb:
#!/usr/local/bin/ruby -w
# encoding: UTF-8
#
# A simply `p4 diff` output colorizer.
# Got this from:
# http://writequit.org/blog/?p=341

FILE_R = /^====\s+([\s\S]+)(#\d+) - ([\s\S]+) ====$/
POS_R  = /^(\d+[ad]\d+)$/
OUT_R  = /^< /
IN_R   = /^> /

## Escape sequences for colors
## Misc
$RESET = "\033[0m"
$BOLD = "\033[1m"
$BLINK = "\033[5m"

## Foreground colors
$BLACK = "\033[30m"
$RED = "\033[31m"
$GREEN = "\033[32m"
$BROWN = "\033[33m"
$BLUE = "\033[34m"
$MAGENTA = "\033[35m"
$CYAN = "\033[36m"
$WHITE = "\033[37m"

$stdin.each_line do |line|
  line.chomp!
  if line =~ FILE_R
    puts "#{$MAGENTA}" + line + "#{$RESET}"
  elsif line =~ POS_R
    puts "#{$CYAN}" + line + "#{$RESET}"
  elsif line =~ OUT_R
    puts "#{$RED}" + line + "#{$RESET}"
  elsif line =~ IN_R
    puts "#{$GREEN}" + line + "#{$RESET}"
  else
    puts line
  end
end
You can call it like this...
$ p4 diff Module.pm | ~/bin/p4c.rb
# or with an alias: colorize='~/bin/p4c.rb'
$ p4 diff Module.pm | colorize