Why, why, why …. CLI? Command line is a great interface choice: •use the same tools everywhere •transferrable CLI-wrangling skills •command names are searchable •scripts to save and replay commands
@lornajane@indieweb.social, @lornajane.net (bsky)
Redirect operator Take the output and put it in a file. ls *.md > files_list.txt
Capture output to share or use later
@lornajane@indieweb.social, @lornajane.net (bsky)
Slide 5
Pipe operator Send output of one command as input to another. grep -Ri Flamingo * | wc -l
Tools each do one thing well. We combine them as we please.
@lornajane@indieweb.social, @lornajane.net (bsky)
Slide 6
Regular expressions “RegEx” is a way to describe complex and flexible character matching. /h.*p # matches “hip” “hoop” and “hippo camp” /^The # only matches The (or Theatre, etc) after a newline s/=/-/g # replace all = with -
@lornajane@indieweb.social, @lornajane.net (bsky)
ls List command. ls ls ls ls ls ls
.md **/.md -l -lt -ltr
Use with cd to change directory.
@lornajane@indieweb.social, @lornajane.net (bsky)
Slide 9
tree Representation of files/folders tree tree -L 1 keys
Also a good visualisation tool for including in docs.
@lornajane@indieweb.social, @lornajane.net (bsky)
sed Find and replace in multiple files. sed -i ‘s/Vale\b/VALE/g’ styles.md
see also: vim macros, or IDE find/replace with regex.
@lornajane@indieweb.social, @lornajane.net (bsky)
diff Choose a diff tool to work with versions of content. cp index.md myindex.md vim myindex.md # make changes diff index.md myindex.md vimdiff index.md myindex.md
Your Editor/IDE may have this feature.
@lornajane@indieweb.social, @lornajane.net (bsky)
Slide 16
git diff(tool) Git can show diffs in nice tools too git diff git difftool
Configure it: git config diff.tool vimdiff
@lornajane@indieweb.social, @lornajane.net (bsky)
pandoc Pandoc is a document format conversion multitool. pandoc install.md -o install.pdf pandoc install.md -o install.html pandoc install.md -o install.rst
Styles and templates can be adjusted.
@lornajane@indieweb.social, @lornajane.net (bsky)
Slide 19
convert Part of the ImageMagick library: converts images. • convert action.png -resize 10% •Resize •Reduce file size (compress) •Change image format
action-new.png
Also identify to check the properties of an image. @lornajane@indieweb.social, @lornajane.net (bsky)
Scripts are repeatable Write a shell script to use exactly the same commands every time. #!/bin/bash convert action.png -resize 10% action-new.png convert error.png -resize 10% error-new.png
Scripts can accept input too
@lornajane@indieweb.social, @lornajane.net (bsky)
Slide 22
CLI Magic Tricks for Docs Projects
@lornajane@indieweb.social, @lornajane.net (bsky)