Coder Social home page Coder Social logo

hulxv / hydra Goto Github PK

View Code? Open in Web Editor NEW

This project forked from emad-elsaid/hydra

0.0 0.0 0.0 173 KB

๐“†š C implementation of the famous Emacs Hydra package to be used in terminal. Groups commands and assign each command a key binding

Home Page: https://hydra.emadelsaid.com/

License: GNU General Public License v3.0

Shell 3.55% C 92.65% Makefile 3.79%

hydra's Introduction

๐“†š Hydra

a C implementation of Emacs Hydra package to be used in terminal.

asciicast

What is ๐“†š Hydra?

  • An implementation of Emacs ๐“†š Hydra functionality to be used in the terminal
  • a terminal program that groups your commands and bind them to common key on your keyboard.
  • Commands can also be grouped in a tree like structure each node in the tree has a name and key bound to it.
  • It reads CSV files of key,name,command lines then shows Terminal UI similar to Emacs ๐“†š Hydra and prints the command to stdout.

Spacemacs for example is an emacs configuration centered around ๐“†š Hydra commands, with all user commands grouped as trees bound in a mnemonic way. for example:

  • opening a file is bound to space f f
  • deleting current file is bound to space f D
  • Git status space g s

Binding ๐“†š Hydra to space key in your terminal means pressing space will make your terminal behave similar to spacemacs if you executed the output with eval. this repo has a bash script hydra-completion.bash which achieve this binding.

Other usages

  • hydra doesn't execute the command by default.
  • The program prints the choosen command to standard output.
  • What to do with this output is up to you. you can for example append it to a file. or open the browser with the output or whatever. just like fzf and dmenu.
  • Which means you can use ๐“†š Hydra as part of your scripts to allow the user to navigate a tree of choices and get the final choice piped to another program, GNU coreutils style.

Install

  • Clone it from github to your machine
git clone [email protected]:emad-elsaid/hydra.git
cd hydra
  • Build
make
  • Install
sudo make install
  • Export HYDRA variable to your .bashrc. it should have a list of hydras files. ๐“†š Hydra example files are installed under /usr/share/hydra/hydras.
  • Loading /usr/share/hydra-completion.bash will bind hydra to Space key in your keyboard and will invoke hydra when the line is empty.
  • For example to use the git ๐“†š Hydra:
export HYDRA="/usr/share/hydra/hydras/git"
source /usr/share/hydra/hydra-completion.bash

๐“†š Hydra file

  • ๐“†š Hydra files are simple CSV files that define the commands ๐“†š hydra can load.
  • The file has 3 columns without header. an example is under hydras directory in this repo.

a simple example can be as follow

g,Git,
gs,Status,git status
  • It defines Git command that doesn't execute a command under the key g
  • and defines a command named Status under key s inside g that will execute the command git status

Running

  • You can run hydra binary with a list of ๐“†š hydra files
  • ๐“†š Hydra will load the files in the order passed.
  • it will display the list of top level commands
  • When the program reaches a choosen command that doesn't have children it will print the command to standard output
hydra hydras/git hydras/systemd hydras/github

Tests

To run tests execute

make run-test

hydra's People

Contributors

emad-elsaid avatar hulxv avatar carabolic avatar

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.