Using Pen.el on the CLI to generate code snippets
Summary
I wanted to demo some of the code gen commands using the cli interface with org-babel.
Demos
|
|
s = "hello world"
print s.split()
# ['hello', 'world']
|
|
declare -a arr=([1]=1 [2]=2 [3]=3 [4]=4)
declare -a arr=(1 2 3 4 5)
declare -a array=(a b c d e f g)
save_array=(${!array[@]}
a=(1 2 3 4 5);
b=$a;
c=${b#*#};
# add the array to the end of somefile
arr=($(uname -r -m))
echo "$arr" > /home/user/benchmarks/benchmark
# extract it
cat /home/user/benchmarks/benchmark | grep -Po '
|
|
:%s/^\d+/\1+/g
:%s/\d\+/\1+/g
:%s/\d/\1+/g
:%s/\d\+/\=line(".")+1/g
:%s/^\d\+\s\d\+\s\d\+\s\d\+\s\d\+\s\d\+\s\d\+\s\d\+\s\d\+\s
|
|
crontab -e
2 0 * * * rsync -ahz --delete -e "ssh -i ~/.ssh/google_compute_engine"
$HOME/ gs://my-bucket/
</nowiki>
# Find all files in current directory that
crontab -e
0 */12 * * * rsync -a --delete ~/ /cloud/
crontab -l | { cat; echo "@daily google-drive sync ~/ s3://mybucket"; }
# delete a file and receive output by email
$ echo "foo" > /root/backup.txt && mail -s "Backup" backup@example
crontab -e
# */5 * * * * rclone sync /home/ <yourusername> @drive.google.com: /home/ <yourusername> --quiet
$ crontab -eย
# at 23:50 (11:50pm)
crontab -e
$ * * * * * rsync -a ~ / /backup/backup.tar.gz
$ * * * * * rsync -a ~ / /backup/home.tar.gz
$ crontab -l
$ cr
|
|
pacman -Rns
pacman -Qq | awk '{print "pacman -Rs " $1 }' | sh
pacman -Qq | pacman -Ql | xargs sudo pacman -Rns
pacman -Q
# Delete all files
pacman -Qq | pacman -Rs
pacman -Qqen *
TODO parameterize the mode-sensitive prompts for the CLI
|
|
Thanks for reading!
If this article appears incomplete, it may be intentional. Try prompting for a continuation.
If this article appears incomplete, it may be intentional. Try prompting for a continuation.