Giter Site home page Giter Site logo

icl's Introduction

icl - interactive command library

icl is a user-friendly, interactive cheat sheet for your UNIX terminal.

Have your favorite one-liners allways at your fingertips.

Example

Installation

One line installation is provided for convenience, but you are encouraged to read the installation scripts.

Fish shell

curl -sSL https://raw.githubusercontent.com/plainas/icl/master/install_fish.sh | /bin/sh

Reload your fish config or start a new shell.

Note: If you are still using fish 2, you need to define the keybinding to ''f_run_icl'' yourself.

Z shell

curl -sSL https://raw.githubusercontent.com/plainas/icl/master/install_zsh.sh | /bin/sh

reload zsh config or relaunch zsh.

Bash

curl -sSL https://raw.githubusercontent.com/plainas/icl/master/install_bash.sh | /bin/sh

Bash doesn't lend itself to the same level of interactivity and configurability as fish or zsh.

The command below will install a function to launch icl by pressing Ctrl+t, on your .bashrc . The chosen command is placed in your input bugger but it is also printed to stdout. This works but it is somewhat anoying. If you are bash user, this is good time to switch to fish.

Manual Installation

icl command is just a single python script with no dependencies on third party modules. By itself, it just launches the interactive search UI and, once you pick a command by pressing enter, will send it to SDOUT. This is not too useful. For a streamlined experience, install the helper functions for your shell and bind them to shortcut. They will launch icl on a keybind and, once you pick the command, place it in your input buffer. Check icl.fish, icl.bash.sh and icl.zsh.sh for ready to use helper functions and keybinding definitions.

  1. Download icl.py, set the execution bit and place it somewhere on your $PATH.

  2. Install the helper functions and keybinds for your shell.

Usage

Just press Ctrl+t and start typing.

Pick the command you want by pressing enter. To abort press Ctrl+C

Add commands to your cheat sheet

Commmands are stored in ~/.config/icl/commands.txt

You can edit that file and add your favorite oneliners.

The format is self explanatory:


# description lines starts with '#', the command follows in the next line
fortune

# This line is here just to hold a brief command description
echo "This sample command echoes this!" 

# List all processes
ps aux

Change the keybind

If you installed icl with the one line snippets provided above. The keybind is defined in ~/.config/fish/config.fish , ~/.bashrc or ~/.zshrc depending on which shell you are using. Look for one of the following commands and replace ctrl+t with another keybind on your preference.

# fish
bind \ct f_run_icl

# zsh
bindkey ^t w_run_icl

# Bash
bind '"\C-t":"f_run_icl\n"'

Bonus: icl as a TLDR client

The file tldr.txt includes all commands scrapped from tldr repository. If you want to be able to access them using icl, simply place them in your commands.txt. You can do so by running the following command.

curl https://raw.githubusercontent.com/plainas/icl/master/tldr.txt >> ~/.config/icl/commands.txt

TODO

  • accept an url as parameter to load an online library
  • include cheat and eg
  • integrate client to bropages
  • Improve TLDR scraper, get ridd of curly brackets around paremeters.

icl's People

Contributors

canute24 avatar cibinmathew avatar plainas 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

Watchers

 avatar  avatar  avatar  avatar

icl's Issues

Support more types of searches

Support more types of comment-command pairs that can be listed in the suggestions

It seems currently only below is supported

# first line should be a comment line
This line will be pasted if selected as a match
  1. Support group comment followed by multiple lines
    eg: on searching --> 'git tricks modified' show the top comment followed 'git ls-files --modified'
# git ls tricks
git ls-files
git ls-files  --modified 
  1. Support lines without a preceding comment(comment can be on same line towards the end)
    eg:
git ls-files --modifed  # git trick list modified files only

Thoughts and other useful scenarios?

Allow multipage navigation

what if I want a page for bash commands and another for docker and another for git?
I already implemented this, I added right and left arrows to switch between cheatsheets. also added page-down, page-up, end and home keys support. also made the search smarter.
ill probably make a merge request soon.

Add note on changing the default keybindings

Great tool ๐Ÿ‘ Maybe adding a note on changing the default keybindings in the README would be useful - albeit trivial for ^t but where can I turn off the <tab> binding? ๐Ÿ˜…

Escape key to exit icl

Feature Request
Exit using escape key as an alternative binding in addition to Ctrl-c

Would it be possible to add something here or is it handled somewhere

icl/icl.py

Lines 186 to 193 in c0aefca

def _handle_keypress(self, pressed_key):
if pressed_key == 8 or pressed_key == 127 or pressed_key == curses.KEY_BACKSPACE:
self.input_string = self.input_string[:-1]
elif pressed_key == curses.KEY_ENTER or pressed_key == 10 or pressed_key == 13:
final_output=self.matches[self.selected_option_index][1]

Add a menu to pick among multiple files

Preliminary discussion about multiple 'libraries' can be found here:
#7

By introducing an external dependency, this could be trivially.

The three libraries bellow, all provide direct ways to create a TUI select menu. But as far as I can tell, they all will take up the whole screen, which could be confusing/ ugly.

A small popup floating box preserving the current state in the background would be the optimal solution. This shouldn't be too difficult with curses only.

A few TUI libraries might have this functionality, or at least something in those lines is probably implemented somewhere in their code:

Load the command list from an url

Allow passing an url pointing to the command list when launching icl. Use -u /--url. The file could contain escape sequences that are injected in the terminal. This is essentially a blatant window for remote code execution. So needs to be used with full awareness of the risks.

  • For safety reasons only https should be allowed.
  • Disable this feature by default or show a huge red warning each time this is used. Use an environment variable to allow disabling this security check.

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.