/action

the simplest, yet powerful autocomplete tool for command line with fzf

Primary LanguageShell

Art Deco fonts

The simplest, yet powerful autocomplete tool for command line with fzf.

It follows the intuitive way to write reusable code. No magic.

demo

How to use

  1. Install fzf first.
  2. Install bat for colorize.
  3. chmod -R 777 ${pwd}/actions
  4. Set ${pwd}/action/bin in your PATH, you are ready to go.

Quick start

Have fun with the built-in actions

> action

Make your own action

  1. Fork this repo.

  2. Code some script in any language you want, put them in ${pwd}/actions/. Or you can use the action to create the action. action | create action.sh.

  3. chmod the file, done.

Write an action in sh

Ex: The simplest script demo, check out actions/python ftp.sh

#!/bin/bash
python -m pyftpdlib

Ex: With Color Input, turn Spotlight index on or off. actions/toggle spotlight.sh

#!/bin/bash
source "$(dirname "$0")/../util/base.sh"
# -------------------------------------------
input flick "开或关 (on|off)" 
sudo mdutil -a -i $flick

2022-10-07 11.57.21

Ex: With Simple Input, actions/按升序显示目标文件夹大小.sh

#!/bin/bash
source "$(dirname "$0")/../util/base.sh"
# -------------------------------------------
directory=$(input2 "文件夹位置: ")
du -h -d 2 $directory | gsort -h

2022-10-07 12.01.35

Input Variable

Variable could be input typing, also could be fzf list or any other source. Use you imagination.

util/base.sh supplies 3 useful input wrapper funtions for common bash usage.

simple input

Simple as it is, robust but without color.

image-20221007145459152

directory=$(simple_input "文件夹位置: ")

color input

color input is a bit tricky. If you input may represent a relative path, you should always add this code localBranch="${localBranch/#\~/$HOME}", otherwie ~ won't expand because of input is a pure string.

image-20221007144734144

color_input localBranch "本地分支名" 
localBranch="${localBranch/#\~/$HOME}"

fzf input

2022-10-07 14.35.32

remoteBranch=`fzf_input "远程分支名" git branch -r`

TODO

  • Install action with curl
  • More source support other than the actions folder

Similar tools

beavr, bro, cheat, cheat.sh, cmdmenu, eg, how2, howdoi tldr, navi

reference

https://seb.jambor.dev/posts/improving-shell-workflows-with-fzf/