awesome percol examples

Feb 4, 2017   (8 minute read)   #bash 

What is Percol?

Percol is a Python utility for unix that adds an interactive selection menu to your terminal. This menu can be generated instantly just from piping from a different command.

If I missed your favorite way of using percol, please send me a tweet and I’ll add your suggestions to this list.

Common UNIX Stuff

Search a File

percol /path/to/file

searching file with percol

Changing Directories

cd $(ls -ARd */ | percol)

changing directories with percol

Killing Processes

ps aux | percol | awk '{ print $2 }' | xargs kill

killing processes with percol

Run a Command from History

eval $(history | cut -c 8- | percol)

run history command with percol

Search grep Results

grep -R "needle" haystack/ 

search grep results with percol

Open grep Result File with vim

vim $(grep -R 'needle' haystack/ | percol | awk -F ':' '{print $1}')

open grep result in vim with percol

Parsing diff Output

diff file1 file2 | percol

parsing diff output with percol

Search for alias

alias | percol

search for alias with percol

Choose User for File Ownership

sudo chown $(cut -d: -f1 /etc/passwd | percol) file

choose user for file ownership with percol

Choose Group for File Ownership

sudo chgrp $(groups | tr " " '\n' | percol) file

choose group for file ownership with percol

Percol with Docker

Choose Running Container to Stop

docker stop $(docker ps | percol | awk '{print  $1;}')

choose running container to stop with percol

Choose Stopped Container to Start

docker start $(docker ps --filter 'status=exited' | percol | awk '{print $1;}')

choose stopped container to start with percol

Choose Container to Remove

docker rm $(docker ps -a | percol | awk '{print $1;}')

choose container to remove with percol

Choose Image to Remove

docker rmi $(docker images | percol | awk '{print $3;}')

choose image to remove with percol