Last active
August 29, 2015 13:57
-
-
Save jettero/9785553 to your computer and use it in GitHub Desktop.
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
| #!/bin/bash | |
| # don't run this, source it | |
| # source cisco-like-help.sh | |
| function ciscolikehelp() { | |
| if [[ $READLINE_POINT=${#READLINE_LINE} && "$READLINE_LINE" =~ \ $ ]]; then | |
| cmd="$( sed -e 's/.*[;|]//' -e "s/ .*//g" <<< "$READLINE_LINE" )" | |
| pcmd=$( type -P $cmd ) | |
| TYPE=$( type -t ${pcmd:-$cmd} ) | |
| case "$cmd-$TYPE" in | |
| *-builtin) | |
| echo | |
| echo "-----:= $READLINE_LINE help" | |
| help $cmd | less -E | |
| return | |
| ;; | |
| ip-*) | |
| echo | |
| echo "-----:= $READLINE_LINE help" | |
| $READLINE_LINE help | less -E | |
| return | |
| ;; | |
| *-file) | |
| echo | |
| echo "-----:= $cmd --help" | |
| $cmd --help | less -E | |
| return | |
| ;; | |
| esac | |
| READLINE_LINE+=? | |
| READLINE_POINT=$(( READLINE_POINT + 1 )) | |
| fi | |
| } | |
| function enableciscolikehelp() { | |
| bind -x '"?":ciscolikehelp' | |
| alias clh=disableciscolikehelp | |
| export CLHS="?" | |
| } | |
| function disableciscolikehelp() { | |
| bind $'\077':self-insert | |
| alias clh=enableciscolikehelp | |
| unset CHLS | |
| } | |
| enableciscolikehelp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment