Created
October 1, 2015 00:15
-
-
Save breezhang/a69b11848c544f9b36d6 to your computer and use it in GitHub Desktop.
command fu
This file contains 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
need jq | |
cli pipe jq some stuff | |
need code .... |
This file contains 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/sh | |
# | |
# commandlinefu - Simple shell script using commandlinefu.com API | |
# | |
# All commands sorted by date: | |
# % commandlinefu | |
# | |
# All commands sorted by votes: | |
# % commandlinefu -v | |
# | |
# Search results for the query 'ssh' sorted by date: | |
# % commandlinefu ssh | |
# | |
# Search results for the query 'ssh' sorted by votes: | |
# % commandlinefu -v ssh | |
# | |
# You can learn more about commandlinefu.com API at the following link: | |
# http://www.commandlinefu.com/site/api | |
# | |
# Original script: | |
# http://commandlinefu.uservoice.com/forums/11102-general/suggestions/116596-provide-bash-client-to-integrate-site-into-cli | |
# | |
# Seungwon Jeong <[email protected]> | |
# | |
# Copyright (C) 2011 by Seungwon Jeong | |
set -e | |
if test "$1" = -v; then | |
sort=sort-by-votes | |
shift | |
fi | |
base_url=http://www.commandlinefu.com/commands | |
if test "$1"; then | |
query=$1 | |
base64=`echo -n $query | base64` | |
command_set=matching/$query/$base64 | |
else | |
command_set=browse | |
fi | |
if test "$sort"; then | |
command_set=$command_set/$sort | |
fi | |
format=json | |
url=$base_url/$command_set/$format | |
curl $url |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment