├── README.mdown ├── Commands ├── Help.tmCommand ├── ctrl-shift-1.plist ├── ctrl-shift-2.plist ├── ctrl-shift-3.plist ├── ctrl-shift-4.plist └── ctrl-shift-5.plist ├── info.plist └── Support └── hotkey.rb /README.mdown: -------------------------------------------------------------------------------- 1 | # Installation 2 | 3 | You can install this bundle in TextMate by opening the preferences and going to the bundles tab. After installation it will be automatically updated for you. 4 | 5 | # General 6 | 7 | * [Bundle Styleguide](http://kb.textmate.org/bundle_styleguide) — _before you make changes_ 8 | * [Commit Styleguide](http://kb.textmate.org/commit_styleguide) — _before you send a pull request_ 9 | * [Writing Bug Reports](http://kb.textmate.org/writing_bug_reports) — _before you report an issue_ 10 | 11 | # License 12 | 13 | If not otherwise specified (see below), files in this repository fall under the following license: 14 | 15 | Permission to copy, use, modify, sell and distribute this 16 | software is granted. This software is provided "as is" without 17 | express or implied warranty, and with no claim as to its 18 | suitability for any purpose. 19 | 20 | An exception is made for files in readable text which contain their own license information, or files where an accompanying file exists (in the same directory) with a “-license” suffix added to the base-name name of the original file, and an extension of txt, html, or similar. For example “tidy” is accompanied by “tidy-license.txt”. -------------------------------------------------------------------------------- /Commands/Help.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | bundleUUID 8 | 5AE8DC40-A7BB-4E63-AE9B-D7E24C2E339C 9 | command 10 | . "$TM_SUPPORT_PATH/lib/webpreview.sh" 11 | html_header "Hotkey Help" "Hotkey" 12 | Markdown.pl <<'EOF' 13 | <title>Hotkey Bundle</title> 14 | 15 | ## About 16 | 17 | The hotkey bundle allows you to store a shell command on control shift 1-5 (US keymap) for the current project. 18 | 19 | ## How it works 20 | 21 | The first time you press control shift 1-5, it will ask you for the shell command to run. After that, the same key will run that command with output shown as a tool tip. All commands are run from the base of the project directory. 22 | 23 | ## Internals 24 | 25 | The list of recorded shell commands is kept in the project folder as `.tmhotkeys` (in YAML format). 26 | 27 | EOF 28 | html_footer 29 | input 30 | none 31 | name 32 | Help 33 | output 34 | showAsHTML 35 | uuid 36 | 18C33747-DEB1-4F36-B1E3-EF1D544C1D96 37 | 38 | 39 | -------------------------------------------------------------------------------- /Commands/ctrl-shift-1.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | cd ${TM_PROJECT_DIRECTORY} 9 | ruby18 <<'EOF' 10 | 11 | num = 1 12 | 13 | `"#{ENV['TM_BUNDLE_SUPPORT']}/hotkey.rb" -n #{num} -c "#{ENV['TM_PROJECT_DIRECTORY']}/.tmhotkeys" --check` 14 | if($? == 0) 15 | print `"#{ENV['TM_BUNDLE_SUPPORT']}/hotkey.rb" -n #{num} -c "#{ENV['TM_PROJECT_DIRECTORY']}/.tmhotkeys"` 16 | exit() 17 | end 18 | 19 | output = `CocoaDialog inputbox --title Input --informative-text 'What command should be run?' --button1 Record --button2 'Cancel'` 20 | output = output.split("\n") 21 | 22 | # check the button pressed, exit if it wasn't Record 23 | if(output[0] !~ /^1$/) 24 | exit 25 | end 26 | 27 | # update the command 28 | `"#{ENV['TM_BUNDLE_SUPPORT']}/hotkey.rb" -n #{num} -c "#{ENV['TM_PROJECT_DIRECTORY']}/.tmhotkeys" -u '#{output[1].strip.gsub(/'/, '\\\\1')}'` 29 | 30 | # run the command 31 | print `"#{ENV['TM_BUNDLE_SUPPORT']}/hotkey.rb" -n #{num} -c "#{ENV['TM_PROJECT_DIRECTORY']}/.tmhotkeys"` 32 | 33 | input 34 | none 35 | keyEquivalent 36 | ^! 37 | name 38 | ctrl-shift-1 39 | output 40 | showAsTooltip 41 | uuid 42 | 52991D39-38F1-4A33-9C7D-5D39EB289889 43 | 44 | 45 | -------------------------------------------------------------------------------- /Commands/ctrl-shift-2.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | cd ${TM_PROJECT_DIRECTORY} 9 | ruby18 <<'EOF' 10 | 11 | num = 2 12 | 13 | `"#{ENV['TM_BUNDLE_SUPPORT']}/hotkey.rb" -n #{num} -c "#{ENV['TM_PROJECT_DIRECTORY']}/.tmhotkeys" --check` 14 | if($? == 0) 15 | print `"#{ENV['TM_BUNDLE_SUPPORT']}/hotkey.rb" -n #{num} -c "#{ENV['TM_PROJECT_DIRECTORY']}/.tmhotkeys"` 16 | exit() 17 | end 18 | 19 | output = `CocoaDialog inputbox --title Input --informative-text 'What command should be run?' --button1 Record --button2 'Cancel'` 20 | output = output.split("\n") 21 | 22 | # check the button pressed, exit if it wasn't Record 23 | if(output[0] !~ /^1$/) 24 | exit 25 | end 26 | 27 | # update the command 28 | `"#{ENV['TM_BUNDLE_SUPPORT']}/hotkey.rb" -n #{num} -c "#{ENV['TM_PROJECT_DIRECTORY']}/.tmhotkeys" -u '#{output[1].strip.gsub(/'/, '\\\\1')}'` 29 | 30 | # run the command 31 | print `"#{ENV['TM_BUNDLE_SUPPORT']}/hotkey.rb" -n #{num} -c "#{ENV['TM_PROJECT_DIRECTORY']}/.tmhotkeys"` 32 | 33 | input 34 | none 35 | keyEquivalent 36 | ^@ 37 | name 38 | ctrl-shift-2 39 | output 40 | showAsTooltip 41 | uuid 42 | 768F3AD8-30D7-4AFD-8041-5F02E5EADD44 43 | 44 | 45 | -------------------------------------------------------------------------------- /Commands/ctrl-shift-3.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | cd ${TM_PROJECT_DIRECTORY} 9 | ruby18 <<'EOF' 10 | 11 | num = 3 12 | 13 | `"#{ENV['TM_BUNDLE_SUPPORT']}/hotkey.rb" -n #{num} -c "#{ENV['TM_PROJECT_DIRECTORY']}/.tmhotkeys" --check` 14 | if($? == 0) 15 | print `"#{ENV['TM_BUNDLE_SUPPORT']}/hotkey.rb" -n #{num} -c "#{ENV['TM_PROJECT_DIRECTORY']}/.tmhotkeys"` 16 | exit() 17 | end 18 | 19 | output = `CocoaDialog inputbox --title Input --informative-text 'What command should be run?' --button1 Record --button2 'Cancel'` 20 | output = output.split("\n") 21 | 22 | # check the button pressed, exit if it wasn't Record 23 | if(output[0] !~ /^1$/) 24 | exit 25 | end 26 | 27 | # update the command 28 | `"#{ENV['TM_BUNDLE_SUPPORT']}/hotkey.rb" -n #{num} -c "#{ENV['TM_PROJECT_DIRECTORY']}/.tmhotkeys" -u '#{output[1].strip.gsub(/'/, '\\\\1')}'` 29 | 30 | # run the command 31 | print `"#{ENV['TM_BUNDLE_SUPPORT']}/hotkey.rb" -n #{num} -c "#{ENV['TM_PROJECT_DIRECTORY']}/.tmhotkeys"` 32 | 33 | input 34 | none 35 | keyEquivalent 36 | ^# 37 | name 38 | ctrl-shift-3 39 | output 40 | showAsTooltip 41 | uuid 42 | 5CFF88D2-658D-4E81-9FCA-45673D3E74DD 43 | 44 | 45 | -------------------------------------------------------------------------------- /Commands/ctrl-shift-4.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | cd ${TM_PROJECT_DIRECTORY} 9 | ruby18 <<'EOF' 10 | 11 | num = 4 12 | 13 | `"#{ENV['TM_BUNDLE_SUPPORT']}/hotkey.rb" -n #{num} -c "#{ENV['TM_PROJECT_DIRECTORY']}/.tmhotkeys" --check` 14 | if($? == 0) 15 | print `"#{ENV['TM_BUNDLE_SUPPORT']}/hotkey.rb" -n #{num} -c "#{ENV['TM_PROJECT_DIRECTORY']}/.tmhotkeys"` 16 | exit() 17 | end 18 | 19 | output = `CocoaDialog inputbox --title Input --informative-text 'What command should be run?' --button1 Record --button2 'Cancel'` 20 | output = output.split("\n") 21 | 22 | # check the button pressed, exit if it wasn't Record 23 | if(output[0] !~ /^1$/) 24 | exit 25 | end 26 | 27 | # update the command 28 | `"#{ENV['TM_BUNDLE_SUPPORT']}/hotkey.rb" -n #{num} -c "#{ENV['TM_PROJECT_DIRECTORY']}/.tmhotkeys" -u '#{output[1].strip.gsub(/'/, '\\\\1')}'` 29 | 30 | # run the command 31 | print `"#{ENV['TM_BUNDLE_SUPPORT']}/hotkey.rb" -n #{num} -c "#{ENV['TM_PROJECT_DIRECTORY']}/.tmhotkeys"` 32 | 33 | input 34 | none 35 | keyEquivalent 36 | ^$ 37 | name 38 | ctrl-shift-4 39 | output 40 | showAsTooltip 41 | uuid 42 | 8BEF616A-19A7-4AE2-AC59-B812BF701269 43 | 44 | 45 | -------------------------------------------------------------------------------- /Commands/ctrl-shift-5.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | cd ${TM_PROJECT_DIRECTORY} 9 | ruby18 <<'EOF' 10 | 11 | num = 5 12 | 13 | `"#{ENV['TM_BUNDLE_SUPPORT']}/hotkey.rb" -n #{num} -c "#{ENV['TM_PROJECT_DIRECTORY']}/.tmhotkeys" --check` 14 | if($? == 0) 15 | print `"#{ENV['TM_BUNDLE_SUPPORT']}/hotkey.rb" -n #{num} -c "#{ENV['TM_PROJECT_DIRECTORY']}/.tmhotkeys"` 16 | exit() 17 | end 18 | 19 | output = `CocoaDialog inputbox --title Input --informative-text 'What command should be run?' --button1 Record --button2 'Cancel'` 20 | output = output.split("\n") 21 | 22 | # check the button pressed, exit if it wasn't Record 23 | if(output[0] !~ /^1$/) 24 | exit 25 | end 26 | 27 | # update the command 28 | `"#{ENV['TM_BUNDLE_SUPPORT']}/hotkey.rb" -n #{num} -c "#{ENV['TM_PROJECT_DIRECTORY']}/.tmhotkeys" -u '#{output[1].strip.gsub(/'/, '\\\\1')}'` 29 | 30 | # run the command 31 | print `"#{ENV['TM_BUNDLE_SUPPORT']}/hotkey.rb" -n #{num} -c "#{ENV['TM_PROJECT_DIRECTORY']}/.tmhotkeys"` 32 | 33 | input 34 | none 35 | keyEquivalent 36 | ^% 37 | name 38 | ctrl-shift-5 39 | output 40 | showAsTooltip 41 | uuid 42 | 2AD289D4-FBE2-40D2-B12D-3D498486B881 43 | 44 | 45 | -------------------------------------------------------------------------------- /info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | contactEmailRot13 6 | qnivq@tenlfxvrf.arg 7 | contactName 8 | David Powers 9 | description 10 | Allows you to assign a key equivalent to a shell command for the current project only. 11 | mainMenu 12 | 13 | items 14 | 15 | 52991D39-38F1-4A33-9C7D-5D39EB289889 16 | 768F3AD8-30D7-4AFD-8041-5F02E5EADD44 17 | 5CFF88D2-658D-4E81-9FCA-45673D3E74DD 18 | 8BEF616A-19A7-4AE2-AC59-B812BF701269 19 | 2AD289D4-FBE2-40D2-B12D-3D498486B881 20 | ------------------------------------ 21 | 18C33747-DEB1-4F36-B1E3-EF1D544C1D96 22 | 23 | submenus 24 | 25 | 26 | name 27 | Hotkey 28 | ordering 29 | 30 | 52991D39-38F1-4A33-9C7D-5D39EB289889 31 | 768F3AD8-30D7-4AFD-8041-5F02E5EADD44 32 | 5CFF88D2-658D-4E81-9FCA-45673D3E74DD 33 | 8BEF616A-19A7-4AE2-AC59-B812BF701269 34 | 2AD289D4-FBE2-40D2-B12D-3D498486B881 35 | 18C33747-DEB1-4F36-B1E3-EF1D544C1D96 36 | 37 | uuid 38 | 5AE8DC40-A7BB-4E63-AE9B-D7E24C2E339C 39 | 40 | 41 | -------------------------------------------------------------------------------- /Support/hotkey.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby18 2 | 3 | require 'optparse' 4 | require 'yaml' 5 | 6 | module HotKey 7 | 8 | def HotKey.get_options() 9 | options = Hash.new() 10 | 11 | opts = OptionParser.new() { |opts| 12 | opts.on("-c", "--config FILENAME", "Configuration file") { |filename| 13 | options["config"] = filename 14 | } 15 | 16 | opts.on("-n", "--key-number NUM", Integer, "Number of the key to run") { |num| 17 | options["num"] = num 18 | } 19 | 20 | opts.on("-u", "--update COMMAND", "Update --key-number with COMMAND") { |command| 21 | options["command"] = command 22 | } 23 | 24 | opts.on("-C", "--check", "Check if num command is specified") { 25 | options["check"] = true 26 | } 27 | 28 | opts.on_tail("-h", "--help", "Print this message") { 29 | print(opts) 30 | exit() 31 | } 32 | } 33 | 34 | opts.parse(ARGV) 35 | 36 | if(options["config"] == nil) 37 | $stderr.print("Configuration file must be given") 38 | exit!(1) 39 | end 40 | 41 | return(options) 42 | end 43 | 44 | 45 | def HotKey.get_config(filename) 46 | return(YAML.load_file(filename)) 47 | end 48 | 49 | 50 | def HotKey.run(num) 51 | print `#{@config[num]}` 52 | end 53 | 54 | 55 | # Updates command number +num+ to be +command+ 56 | def HotKey.update(command, num, configfile) 57 | @config[num] = command 58 | File.open(configfile, File::CREAT|File::TRUNC|File::WRONLY) { |fp| 59 | fp.write(@config.to_yaml) 60 | } 61 | end 62 | 63 | 64 | def HotKey.main() 65 | options = get_options() 66 | 67 | if(!File.exists?(options["config"])) 68 | @config = Hash.new() 69 | else 70 | @config = get_config(options["config"]) 71 | end 72 | 73 | if(options["check"]) 74 | if(@config.has_key?(options["num"])) 75 | exit(0) 76 | else 77 | exit(100) 78 | end 79 | elsif(options["command"]) 80 | update(options["command"], options["num"], options["config"]) 81 | else 82 | run(options["num"]) 83 | end 84 | end 85 | 86 | end 87 | 88 | HotKey.main() 89 | --------------------------------------------------------------------------------