Created
February 18, 2014 01:16
-
-
Save mooz/9062711 to your computer and use it in GitHub Desktop.
perf made easy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "rios/easy" | |
# http://ascii-table.com/ansi-escape-sequences.php | |
key_remaps = { | |
"j" => "\e[B", # down | |
"k" => "\e[A", # up | |
"o" => "\r\n", # enter | |
"u" => "\e[D", # left | |
} | |
key_remap_pattern = Regexp::new(key_remaps.keys.join("|")) | |
# Hook user's input | |
on_input do |user_input| | |
user_input.gsub(key_remap_pattern) do |original_input| | |
if key_remaps.has_key? original_input | |
key_remaps[original_input] | |
else | |
original_input | |
end | |
end | |
end | |
# Wraps command "perf" | |
listen(["perf"] + ARGV) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment