Skip to content
Browse files

Update README with short example used of _dwim_add_transform

  • Loading branch information...
1 parent a7658ab commit dd157238ceeb8dd0a8a2ede7448b265c5dded2ff @oknowton committed
Showing with 14 additions and 0 deletions.
  1. +14 −0 README.md
View
14 README.md
@@ -60,3 +60,17 @@ Anyone running `zsh` should only need to `source` the `init.zsh` file (run `sour
## Usage
Type a command and hit `control-u` and `zsh-dwim` will attempt to transform your command. Typing `control-u` at an empty command prompt will recall the previous command from your history and then attempt to transform it.
+
+## Creating your own transformations
+
+You can add your own transformations by calling the `_dwim_add_transform` function. This function takes up to three parameters, the third being optional.
+
+ _dwim_add_transform <pattern to match> <code to run> [exit status of previous command]
+
+Here's a simple example:
+
+ ## tar ft -> tar fx (a.k.a. list -> extract)
+ _dwim_add_transform '^tar (ft|tf)' \
+ '_dwim_sed "s/^tar (ft|tf)/tar fx/"'
+
+The `_dwim_sed` function is a little helped function that applies a `sed` regex to the current command.

0 comments on commit dd15723

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