Skip to content

Instantly share code, notes, and snippets.

@adalessa
Created April 27, 2019 17:52
Show Gist options
  • Save adalessa/b2c722004f9f0fbd9e6cf28a58ea0dc4 to your computer and use it in GitHub Desktop.
Save adalessa/b2c722004f9f0fbd9e6cf28a58ea0dc4 to your computer and use it in GitHub Desktop.
Command line scrip for searching laravel documentation
#!/bin/bash
BASE_URL="https://laravel.com/docs/"
VERSION="${LDOC_DEFAULT_VERSION:-5.8}"
OPEN_WITH="xdg-open"
if [ "$1" != "" ]; then
VERSION=$1
fi
FULL_URL="$BASE_URL$VERSION/"
echo $FULL_URL | xargs curl -s | hxnormalize -x | hxselect "section > ul > li > ul > li > a::attr(href)" | sed 's|href|\nhref|g' | sed -r 's/.*href="([^"]*)".*/\1/' | sed 's|/|\ |g' | awk '{print $3}' | sed '/^$/d' | fzf | sed -e 's|^|'"$FULL_URL"'|' | xargs -r $OPEN_WITH
@adalessa
Copy link
Author

This requires to have installed HTML-XML-utils, FZF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment