nobeans / peco-actions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Peco Actions

This command provides the features:

  • Show an appropriate menu for input type.
  • Choose an action from the menu.

Environments

  • Only macOS so far.

Installation

$ go install github.com/nobeans/peco-actions@latest

Usage

usage

usage: peco-actions [option]
options:
  -h,--help             show this usage
  -v,--version          display the version
  -D,--debug            display the version
  --file                actions for file path(s)
  --process             actions for a process id
  --server              actions for a host/IP-address
  --git                 actions for a commit id
  --docker-container    actions for a docker container
  --docker-image        actions for a docker image
  --generic             actions for generic only using adhoc menu

zsh

eval_peco_action() {
    local action="$*"
    if [ -n "$action" ]; then
        echo "$fg_bold[yellow]>> $fg_bold[cyan]$action$reset_color" >&2

        # Add command history
        print -s $action

        # Run by eval to handle arguments including spaces correctly
        # http://labs.opentone.co.jp/?p=5651
        eval $action
    fi
}
$ eval_peco_action $(ls -1 | peco-actions --file)
$ eval_peco_action $(ps | peco | awk '{ print $1 }' | peco-actions --process)

fish

function eval_peco_action
    set -l action "$argv"
    [ -z "$action" ]; and return

    set_color yellow
    echo -n ">> " >&2
    set_color cyan
    echo "$action" >&2
    set_color white

    # Add command history
    fish_add_history "$action"

    # Run by eval to handle arguments including spaces correctly
    eval $action
end
$ eval_peco_action (ls -1 | peco-actions --file)
$ eval_peco_action (ps | peco | awk '{ print $1 }' | peco-actions --process)

About


Languages

Language:Go 98.8%Language:Makefile 1.2%