Skip to content

Instantly share code, notes, and snippets.

@jettero
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save jettero/9785553 to your computer and use it in GitHub Desktop.

Select an option

Save jettero/9785553 to your computer and use it in GitHub Desktop.
#!/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