ljsc / lightning

Speed for your shell and the commandline

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Description

Lightning is a commandline framework that could revolutionize how fast you are on the commandline. Lightning let’s you easily define and generate shell functions which autocomplete and interpret paths (files and directories) by their basenames. With these functions you don’t have to ever type the full path to any file for any command again.

Intro

Lightning generates shell functions which can interpret paths by their basenames. So instead of carpal-typing

$ less /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb

just type

$ less-ruby irb.rb

less-ruby is a lightning function which wraps ‘less` with the ability to refer to system ruby files by their basenames. Being a lightning function, it can also autocomplete system ruby files:

# 1112 available system ruby files
$ less-ruby [TAB]
Display all 1112 possibilities? (y or n)

$ less-ruby a[TAB]
abbrev.rb                  abstract.rb                abstract_index_builder.rb
$ less-ruby abb[TAB]
$ less-ruby abbrev.rb
# Pages /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/abbrev.rb ...

# Autocompletion works regardless of the number of arguments
$ less-ruby -I abbrev.rb y[TAB]
yaml.rb      yamlnode.rb  ypath.rb
$ less-ruby -I abbrev.rb yp[TAB]
$ less-ruby -I abbrev.rb ypath.rb
# Pages /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/abbrev.rb and
  /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/yaml/ypath.rb ...

And here’s the one-liner that creates this function:

$ lightning function create less ruby && lightning-reload

Install

Install with either rip or rubygems:

$ rip install git://github.com/cldwalker/lightning.git
# OR
$ sudo gem install yard # if you want lightning's documentation generated correctly
$ sudo gem install lightning

If you’ve installed with rubygems and ‘time lightning` takes longer than 0.05 seconds, I *strongly recommend* installing with rip. Your startup time directly effects your autocompletion speed with lightning.

Once lightning is installed, we need to do a one-time setup:

# To see available install options
$ lightning install -h

# Installs lightning's core files and sources the needed lightning functions
$ lightning install && source ~/.lightning/functions.sh
Created ~/.lightning_yml
Created ~/.lightning/functions.sh

# To have lightning's functionality loaded when your shell starts up
echo source ~/.lightning/functions.sh >> ~/.bashrc
# or for zsh
echo source ~/.lightning/functions.sh >> ~/.zshrc

Bugs/Issues

Please report them on github.

Limitations

  • Completions that are a directory above or below a basename don’t work for zsh.

  • Only bash and zsh shells are supported. Patches are welcome to support other shells.

Credits

Todo

  • More tests

  • Manpage

  • Consider underscore anchored autocompletion i.e. textmate style file search

  • Possible aliasing of paths per function, bolt or global

  • Possible irb builder using bond

About

Speed for your shell and the commandline

License:MIT License


Languages

Language:Ruby 100.0%