lk

Crates.io

A CLI frontend for your bash scripts, focused on ergonomics.

lk searches for scripts, parses them and finds bash functions. It can then either:

lk's list mode works like this:

A CLI recording showing how you can use lk's list feature

lk's fuzzy mode works like this: A CLI recording showing how you can use lk's fuzzy feature

I use both modes, but I default to fuzzy. You can change the default like this:

A CLI recording showing how you can change lk's default to either list or fuzzy

Features

Installation

From the crate: bash cargo install lk

Update

bash cargo install --force lk

Use

Just execute lk and follow the instructions. lk --help is also a thing you can run.

There are lots of ways to write bash and to organise scripts. lk might not have encountered them all before. If there's a problem I implore you to raise a bug, or just email me. I will fix it.

Why?

  1. You're a polyglot engineer with package manager fatigue. So you want to hide it all behind some bash, the lingua franca.
  2. You do a lot of devops and have a lot of bash.
  3. You have a lot of projects that you don't work on for months at a time, and you need to bring some consistency to the experience of re-visiting them.
  4. You use make and PHONY to do non-compile stuff to your project. lk just lets your write proper bash without all the make specific guff.
  5. You ever copy and paste bash from a text file you keep somewhere.

Use case examples

  1. AWS:
    1. You need to pull down config from AWS and store it in .env files.
    2. You need to switch between AWs environments
  2. You need to build and deploy many services, and want to hide the edge cases. E.g. for compiling, building, and deploying you might have lk my_service jfdi.
  3. You regularly need to set up SSH tunneling and can't remember the commands.

How to write your bash files so they work with lk

Big design goal: you shouldn't have to. But there are many styles of bash, and if lk doesn't work with how you write your bash then please let me know and I'll be all over fixing it.

Having said that lk does support comments. lk will extract comments from file and function headers, if it finds any, and display them alongside all your runnable functions. At the moment it relies on these comments following the form in the Google Shell Style Guide. I.e. like this: ```bash

!/usr/bin/env bash

#

Some comments.

And some more.

A glorious function that does all the things

be_glorious() { echo "Ta da!" } ```

Configuration and logging

There's no configuration file for lk, but it does store logs in ${HOME}/.config/lk.

Why the name "lk"?

If you have any typist home key dicipline and if you flap your right hand at the keyboard there's a good chance you'll type 'lk'. So it's short, and ergonomic.

What's to come?

Inspiration

I have previously written two similar tools: * run_lib - my first draft and written in bash * runsh - my second draft and written in Rust

run_lib still has its uses. I've worked in secure environments where I could not have installed a binary. run_lib is just a bash script.

fzf is wonderful. The --fuzzy option in lk comes from years of ctrl-r fuzzy finding through my shell history with fzf. I almost didn't implement this feature because I thought "why bother? fzf has already done it perfectly." Or rather I thought about piping from lk to fzf. But having the functionality implemented natively is the right thing for lk. But you'll notice, perhaps, that the rendering of the fuzzy search in lk draws a lot of visual inspiration from fzf. fzf, I love you.

Contributing

Contributions are welcome. Thanks to the following for theirs: