1
0
mirror of https://github.com/dcarrillo/prezto.git synced 2024-12-22 08:08:00 +00:00

Added explainshell module

This commit is contained in:
Christian Lentfort 2014-06-18 18:29:26 +02:00 committed by Sorin Ionescu
parent 366cadecf0
commit 0a3d29ce5e
2 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,10 @@
#Explainshell
Adds a keybinding to open (explainshell.com)[http://www.explainshell.com] with the content of the command line.
##Settings
###Key-Binding
The keybinding to open (explainshell.com)[http://www.explainshell.com]
`zstyle ':prezto:module:explainshell' key-binding '^K'`

View File

@ -0,0 +1,38 @@
#
# Adds a explain function and explainshell widget
#
# Authors
# C Lentfort
#
function explain {
# base url with first command already injected
# $ explain tar
# => http://explainshel.com/explain/tar?args=
url="http://explainshell.com/explain/$1?args="
# removes $1 (tar) from arguments ($@)
shift;
# iterates over remaining args and adds builds the rest of the url
for i in "$@"; do
url=$url"$i""+"
done
# opens url in browser
$BROWSER -t $url &> /dev/null
}
function explainshell {
explain $BUFFER
}
zle -N explainshell
zstyle -s ':prezto:module:explainshell' key-binding 'key_binding'
if [[ -n "$key_binding" ]]; then
bindkey "$key_binding" explainshell
fi
unset key_binding