It follows the intuitive way to write reusable code. No magic.
- Install fzf first.
- Install bat for colorize.
chmod -R 777 ${pwd}/actions
- Set ${pwd}/action/bin in your PATH, you are ready to go.
Have fun with the built-in actions
> action
-
Fork this repo.
-
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
. -
chmod the file, done.
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
Ex: With Simple Input, actions/按升序显示目标文件夹大小.sh
#!/bin/bash
source "$(dirname "$0")/../util/base.sh"
# -------------------------------------------
directory=$(input2 "文件夹位置: ")
du -h -d 2 $directory | gsort -h
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.
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.
color_input localBranch "本地分支名"
localBranch="${localBranch/#\~/$HOME}"
fzf input
remoteBranch=`fzf_input "远程分支名" git branch -r`
- Install action with curl
- More source support other than the actions folder
beavr, bro, cheat, cheat.sh, cmdmenu, eg, how2, howdoi tldr, navi
https://seb.jambor.dev/posts/improving-shell-workflows-with-fzf/