GithubHelp home page GithubHelp logo

lightning-cd's Introduction

lightning-cd

asciicast

Lightning is a tool designed to allow you to find and open files as fast as physically possible. It acts as a complement to autojump (https://github.com/wting/autojump); while autojump allows you to go from anywhere to your most accessed directories with just a few keystrokes, Lightning allows you to fly around your filesystem with reckless abandon, flitting through directories and opening files with ease.

Dependencies

Installation

Merely copy lightning-cd.py to someplace convenient and add an alias to it, like so. Lightning takes as its first argument the full path of a file that it writes a directory path to when quitting. If your alias is set up like the below, then you should be able to use Lightning to change your shell's current working directory:

alias i='python3 ~/code/lightning-cd/lightning-cd.py ~/.lightningpath && cd "`cat ~/.lightningpath`"'

Usage

Lightning is an interactive, modal tool with letter keybindings very similar to vim. It contains two modes, search and normal. Normal mode allows you to select a file by moving up and down through a list. Search mode, the default, takes letters that you type, filters them, and then uses them to open a file once the search buffer contains enough to uniquely identify a file.

Common keybindings:

  • Comma moves up one directory
  • Space toggles the mode between search and normal
  • Semicolon quits Lightning
  • Single quote "does the right thing" on either the selected file (normal mode) or the first matching file (search mode)
  • Double quote refreshes the file list
  • Question mark toggles the visibility of "hidden" files (defined by those matching hiddenFilesPattern in settings.py)

Search keybindings:

  • Letters are converted to lowercase, and along with period and numbers are valid search characters
  • Dash removes a character from the search buffer

Normal keybindings:

  • j and k move down and up, respectively
  • f opens the current directory with your file browser (Nautilus by default)
  • t opens Tmux at the current directory

All of the above keybindings can (and should) be changed by editing keybindings.py.

Settings in settings.py:

  • showDeselectedFiles controls the visibility of filenames that don't match the search buffer
  • defaultMode sets the default mode for startup and mode switches
  • fileBrowser is the file browser opened when the file browser shortcut ('f' by default) is pressed
  • persistentMode, if set, causes the current mode to stay the same on directory change
  • lightningPathFile is the path of the file that Lightning writes the directory that should be cd'ed to
  • showHiddenFiles sets the default visibility of hidden files
  • hiddenFilesPattern is the regexp (Python3 re module) that, if matched, declares a pathname (works for files and directories) to be "hidden"
  • restrictBuffer, if set, will cause the search buffer to refuse to accept characters that don't match at least one existing pathname
  • mimePatterns tells Lightning, using mimetypes, how to handle files when told to open them

One of the basic assumptions behind Lightning is that you'll be spending most of your time in search mode, and only switching to normal mode to select files that would otherwise require a (relatively) large number of keystrokes. You may violate this assumption if you wish, at which point you will discover that you are using a watered-down mc (http://www.midnight-commander.org/). Play off Lightning's strengths, avoid its weaknesses (or use another tool), and you may find yourself enjoying productivity gains due to lower mental costs associated with switching source code files.

Disclaimer

Lightning is ALPHA, very much buggy and non-feature-complete, and likely to change very quickly (with changes possibly including a move to another programming language - use at your own risk). With that said, the basic idea (of finding and opening files as quickly as physically possible) will remain the same, and you are encouraged to try it out and give feedback.

(it was also built for a Dvorak Simplified Keyboard user, so you may want to tweak the keybindings for convenience and comfort if you use QWERTY)

lightning-cd's People

Contributors

fouric avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lightning-cd's Issues

add in-program documentation

bind a key that shows documentation in lightning; perhaps add an option to display a "cheat sheet" line at the top or bottom?

Lightning fails to import settings file

When run from anywhere but its project directory, Python throws an ImportError due to not being able to find Lightning's settings file:

Traceback (most recent call last):
  File "/home/user/lightning-cd/lightning-cd.py", line 6, in <module>
    from settings import *
ImportError: No module named settings

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.