Skip to content
Browse files

Add command shortcuts by default.

  • Loading branch information...
1 parent 8d15e2e commit 1b8d28fcfc03ff79bd0803634034fd0c4bd298a2 @netzpirat netzpirat committed
Showing with 16 additions and 20 deletions.
  1. +8 −20 README.md
  2. +8 −0 lib/guard/interactor.rb
View
28 README.md
@@ -460,12 +460,14 @@ Interactions
Guard shows a [Pry](http://pryrepl.org/) console whenever it has nothing to do and comes with some Guard specific Pry
commands:
- * `all` Run all plugins.
- * `change` Trigger a file change.
- * `notification` Toggles the notifications.
- * `pause` Toggles the file listener.
- * `reload` Reload all plugins.
- * `show` Show all Guard plugins.
+ * `↩`, `a`, `all`: Run all plugins.
+ * `h`, `help`: Show help for all interactor commands.
+ * `c`, `change`: Trigger a file change.
+ * `n`, `notification`: Toggles the notifications.
+ * `p`, `pause`: Toggles the file listener.
+ * `r`, `reload`: Reload all plugins.
+ * `s`, `show`: Show all Guard plugins.
+ * `e`, `exit`: Stop all plugins and quit Guard
The `all` and `reload` commands supports an optional scope, so you limit the Guard action to either a Guard plugin or
a Guard group like:
@@ -491,20 +493,6 @@ started. This allows you to make use of the Pry plugin architecture to provide c
your own needs and distribute as a gem. Please have a look at the [Pry Wiki](https://github.com/pry/pry/wiki) for more
information.
-#### Shorthand commands
-
-If you like to have shorthand commands for the built in Guard commands, you can define aliases in your `~/.guardrc`
-file like this:
-
-```Ruby
-%w(help reload change show notification pause exit).each do |command|
- Pry.commands.alias_command command[0].chr, command
-end
-Pry.commands.block_command /^$/, 'Hit Enter to run all tests' do
- Pry.run_command 'all'
-end
-```
-
### Signals
You can also interact with Guard by sending POSIX signals to the Guard process (all but Windows and JRuby).
View
8 lib/guard/interactor.rb
@@ -29,6 +29,14 @@ def initialize
load GUARD_RC if File.exist? File.expand_path GUARD_RC
end
+ %w(help reload change show notification pause exit).each do |command|
+ Pry.commands.alias_command command[0].chr, command
+ end
+
+ Pry.commands.block_command /^$/, 'Hit enter to run all tests' do
+ Pry.run_command 'all'
+ end
+
Pry.config.prompt = [
proc do |target_self, nest_level, pry|
"[#{ pry.input_array.size }] #{ ::Guard.listener.paused? ? 'pause' : 'guard' }(#{ Pry.view_clip(target_self) })#{":#{ nest_level }" unless nest_level.zero? }> "

0 comments on commit 1b8d28f

Please sign in to comment.
Something went wrong with that request. Please try again.