Command line tool to search and view snippets in the terminal
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
clf Fixed errors when clf.yaml is empty Aug 4, 2015
.gitignore Added unit tests Feb 27, 2015
.travis.yml Added the travis badge Mar 2, 2015
LICENSE.txt Initial commit Feb 24, 2015
MANIFEST.in Initial commit Feb 24, 2015
README.rst Updated README.rst Jul 16, 2015
requirements.txt Snippets can be saved locally Aug 4, 2015
setup.py Updated version (0.5.6 -> 0.5.7) Jun 24, 2015
test_clf.py Pep8 fixes Mar 17, 2015
tox.ini Added unit tests Feb 27, 2015

README.rst

clf - Command line tool to search snippets on Commandlinefu.com

https://travis-ci.org/ncrocfer/clf.svg?branch=master

Commandlinefu.com is the place to record awesome command-line snippets. This tool allows you to search and view the results into your terminal.

Example 1

$ clf python server

  # python smtp server
  python -m smtpd -n -c DebuggingServer localhost:1025

  # Python version 3: Serve current directory tree at http://$HOSTNAME:8000/
  python -m http.server

  # Start a HTTP server which serves Python docs
  pydoc -p 8888 & gnome-open http://localhost:8888

  # put current directory in LAN quickly
  python -m SimpleHTTPServer

Example 2

$ clf recursive line count

  # Recursive Line Count
  find ./ -not -type d | xargs wc -l | cut -c 1-8 | awk '{total += $1} END {print total}'

  # Recursive Line Count
  find * -type f -not -name ".*" | xargs wc -l

  # Get Total Line Count Of All Files In Subdirectory (Recursive)
  find . -type f -name "*.*" -exec cat {} > totalLines 2> /dev/null \; && wc -l totalLines && rm totalLines

  # Recursive Line Count
  wc -l `find . -name *.php`

Installation

The tool works with Python 2 and Python 3. It can be installed with Pip :

pip install clf

Usage

Command line tool to search snippets on Commandlinefu.com

Usage:
  clf [options]
  clf <command> [options]
  clf <keyword> <keyword>... [options]

Options:
  -h, --help      Show this help.
  -v, --version   Show version.
  -c, --color     Enable colorized output.
  -i, --id        Show the snippets id.
  -n NUMBER       Show the n first snippets [default: 25].
  --order=ORDER   The order output (votes|date) [default: votes].
  --proxy=PROXY   The proxy used to perform requests.

Examples:
  clf tar
  clf python server
  clf tar --proxy=http://127.0.0.1:8080
  clf --order=date -n 3

Notes

Enable the colorized output

You can set the CLF_COLOR environment variable to enable the colorized output by default :

$ export CLF_COLOR=1

Use clf in your scripts

You can import the clf module and use it in your own scripts :

#!/usr/bin/env python

from clf import Clf

c = Clf()
for cmd in c.browse():
    print("#{}\n{}\n".format(
        cmd.summary,
        cmd.command
    ))