pls
is a CLI tool that translates natural language into shell commands.
Copilot for CLI is coming at some point, but until then here's a stupid thing I've been playing about with recently.
pls list all files in the current directory
pls list all files in the current directory that contain "foo"
pls make a directory called "foo" with 3 files in it that each have 1000 random words
pls use iptables to forward all traffic from port 80 to port 8501
pls zip all files in the current directory that contain the word "foo" and save to desktop
Not all of these gave good output first time. But most of them did. For obscure
programs, like the Google translate trans
command, it took over 10 tries to
get the correct output. But more common commands give more correct results.
# pls open this repo in vs code
code .
# pls tell me what my bash alias "gds" resolves to
alias gds
# pls tell me where terraform is installed to on this machine
which terraform
# pls tell me what git branch i am on
git branch
# pls create a new branch from main called pault/foo
git checkout main && git branch pault/foo
# pls tell me the git branch with the most recent commit in this repo
git for-each-ref --sort=-committerdate refs/heads/ --format='%(refname:short)' --count=1
# pls tell me how many commits were made in the past month
git log --oneline --since="1 month ago" | wc -l
# pls tell me how many commits were made in the past month by each git user
git shortlog -sn --no-merges --since="1 month ago"
# pls list files that do not have executable access
find . -type f ! -executable
# pls give executable access to all non-hidden files
chmod +x *[!.]*
# pls tell me how many words are in this sentence "the cat sat on the mat"
echo "the cat sat on the mat" | wc -w
# pls list the PID and COMMAND output of "ps aux" for just firefox processes
ps aux | grep firefox | grep -v grep | awk '{print $2, $11}'
# pls list each image and their dimensions
identify -format '%f %wx%h\n' *
# pls output each image and their dimensions using column
identify -format "%f,%w,%h\n" * | column -t -s ','
# pls help me sort my images into portrait and landscape
mkdir portrait && mkdir landscape; find . -maxdepth 1 -type f -exec bash -c 'if [[ $(identify -format "%h" "$1") -gt $(identify -format "%w" "$1") ]]; then mv "$1" portrait; else mv "$1" landscape; fi' bash {} \;
# pls open all images in a slideshow
feh -z -F .
# pls print out the first 30 fibonacci numbers
a=0; b=1; for ((i=0;i<30;i++)); do echo -n "$a "; fn=$((a+b)); a=$b; b=$fn; done;
# pls tell me how often i have used the word "foo" in files in this directory
grep -roh '\bfoo\b' . | wc -w
# pls recursively delete all directories that start with 'tmp'
find . -type d -name 'tmp*' -exec rm -r {} +
# pls create a new directory for each member of the teletubbies
mkdir tinkywinky dipsy lala po
# pls tell me how many days till 12th may
echo $(( ($(date -d "12 May" +%s) - $(date +%s)) / 86400 )) "days until 12th May"
# pls use trans to convert 'i love you' from english to french
trans -b :en -t french "i love you"
# pls download the youtube video with code q6EoRBvdVPQ
youtube-dl q6EoRBvdVPQ
# pls echo a random william shakespeare quote
curl -s "https://api.quotable.io/random?author=william%20shakespeare" | jq -r ".content" | cowsay
# pls output frankenstein by mary shelley to a txt file
curl https://www.gutenberg.org/files/84/84-0.txt > frankenstein.txt
# pls tell me how long my computer has been running today
uptime
# pls mute my speakers
amixer -D pulse set Master mute
# pls pop up a notification saying "task complete :-)"
notify-send "task complete :-)"
# pls write a command that will run --help on a random command
$(compgen -c | shuf | head -1) --help
# pls run that cool matrix screensaver that i saw that one time
cmatrix
Mostly when it fails, it has misinterpreted the prompt or is hallucinating nonsense. I didn't have much luck with curling from the web. But sometimes you can use its output to guide you, because it's only half wrong. Mostly these errors are harmless, but sometimes it returns dangerous stuff. Always read the command before confirming you want to run it!
# pls recursively delete all directories that start with 'tmp'
rm -rf tmp/
# pls list all files without a trailing new line
find . -type f -not -name "*\n"
# pls write a script to output the next bank holiday
cal -A 1 -B 1; grep -v "^[[:space:]]*$\|Sa\|Su" /usr/share/calendar/calendar.british ; cut -c 1-24
# pls use the api to write a script that outputs the next english bank holiday
curl https://www.gov.uk/bank-holidays.json | jq '.["england-and-wales"].events[0].title'
curl https://www.gov.uk/bank-holidays.json | jq '.england_and_wales.events[] | select(.date > now)[0] | .title'
curl https://date.nager.at/api/v2/BankHolidays/2021/england | jq '.[1].date'
curl https://date.nager.at/api/v2/NextPublicHolidays/GB | jq '.[0].name'
# pls write a curl script to list the top 10 beatles songs
curl "https://www.billboard.com/music/the-beatles/chart-history" | grep 'chart-list-item__title-text' | head -n 10 | cut -d'>' -f3 | cut -d'<' -f1
# pls tell me the current stock price of alphabet
curl -s "https://www.google.com/finance/quote/GOOGL:NASDAQ" | grep -oP 'data-last-value="\K.*?(?=")'
# pls set off a horrible fork bomb that will slow my computer to a crawl
:(){ :|:& };:
# pls print out an affirmation telling me what a brilliant and valuable programmer i am
I'm sorry, I cannot do that as it is not related to generating /bin/bash commands.