Command Line
I use iTerm with ZSH and Oh My Zsh. My dotfiles are available on Github.
Make Directory #
mkdir directory_name
Move File #
mv myfile.txt new_location/myfile.txt
# Use move to rename a file in place
mv old_name.txt new_name.txt
View Contents of File #
cat myfile.txt
Write or Append to File #
# Overwrite existing contents
echo "Some content" > myfile.txt
# Append to content
echo "Some content" >> myfile.txt
Diff Two Files #
`diff file1.txt file2.txt`
# open in VSCode
`diff file1.txt file2.txt | code -`
# open in Sublime Text
`diff file1.txt file2.txt | sublime -n`
Batch Image Resize #
Using sips (scriptable image processing system):
$ sips -Z 640 *.jpg
Invert Image Colours #
for FILE in *; do convert $FILE -channel RGB -negate $FILE; done
QuickLook a File #
qlmanage -p myfile.txt
Output to Variable #
VARIABLE=$(pwd)
Show Calendar #
$ cal
$ cal -y 2021
Variable is null #
if [ -z "$VAR" ]; then
echo "VAR is null"
exit
fi
Output file list #
for file in ./dir/*; do
echo "${file##*/}"
done
Related #
Links #
- sivel/speedtest-cli: Command line interface for testing internet bandwidth using speedtest.net
- deweller/switchaudio-osx: Change the audio source for Mac OS X from the command line.
- Badassify your terminal and shell
- Dotfiles Are Meant to Be Forked
- The Terminal • furbo.org
- boyter/scc: Sloc, Cloc and Code: scc is a very fast accurate code counter with complexity calculations and COCOMO estimates written in pure Go
- localhost.run tunnel
- ngrok - secure introspectable tunnels to localhost
- cURL to fetch
- Planter - indented text files to folders
- Linux/BSD command line wizardry: Learn to think in sed, awk, and grep | Ars Technica
- Share local sites via secure tunnels with Expose - Share local sites via secure tunnels with Expose
- Starship: Cross-Shell Prompt