Terminal
Useful terminal commands
change screenshot format
defaults write com.apple.screencapture type jpg
killall SystemUIServer
build a Jekyll website and deploy it
#!/bin/bash
JEKYLL_ENV=production bundle exec jekyll build
rsync -avr --rsh='ssh' --delete-after --delete-excluded _site/ username@IP.Add.re.ss:~/notes/_site
note: -avr
could be -avz
instead
Compress a file or a folder
zip -r -X archive-name.zip folder-to-compress
prevent sleep
caffeinate -i -t 3600
Change update interval
defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1
A quick for loop
for f in *.txt; do pandoc '$f' -s -o '${f%.txt}.rtf'; done
Erase disk
sudo diskutil eraseDisk /dev/disk2
Disk space usage
du # dust
lsblk -a -T -h
Storage analyser - YunoHost Forum
With say
, convert a text file to an audio file with Apple’s TTS engine:
say -v Alex -f file.txt -o output.m4a
-v
allows you to select the kind of voice for the output
recursively count files in a directory
find . -type f | wc -l
Recursively copying files from subdirectories to root directory
find ./input/ -type file -exec cp {} ./output/ \;
# or a more modern alternative
fd . ./input/ -t f -x cp {} ./output/ \;
man screencapture
subliminal --opensubtitles xplosionmind 'z#5Br1&9b7niM~QZ$2hJTkn2gQRReJWy4i8zwuF6Pc1wXA#fVIcykUjb' download -l en La.Casa.de.Papel.S05E10.1080p.WEB-DL.DUAL.5.1.mkv
Downgrade package with Homebrew
# remove current version
brew uninstall navi
# find formula/bottle
# launches url
brew info --github navi
# from github url
# 1. locate version
# 2. click 'History'
# 3. locate for the version from @BrewTestBot
# 4. click 'Commit' > 'View File' > Raw
# 5. fetch using `cURL`
curl -O https://raw.githubusercontent.com/Homebrew/homebrew-core/7c7f18795fac61747fe383d7c22ec183d5283362/Formula/navi.rb
# install older version
brew install navi.rb && rm navi.rb
# optional, pin until fix is known
brew pin navi
Resources
- The art of command line, a repository to master command-line usage
- awesome-macos-command-line, a GitHub repository by Marcel Bischoff
- Commandlinefu best commands, a record of little great command line tips
- Handy Bash Shell Aliases For Linux
- Shell commands for simple tasks of processing CSV file
chmod
guide- Linux command line
- A complete dive in the Terminal language, Bash
GPG
sd
sd
is a wonderful command-line tool to find and replace sub-strings in files. Its original version is sed
, which comes by default in shell.
Replace foo
with bar
in all files inside pwd:
sd 'foo' 'bar' ./*
HTML proofer
HTML proofer is a Ruby script to check HTML quality of a local folder. It can both be used as a library and as a command line tool.
basic check of a Jekyll website
bundle exec htmlproofer --assume-extension --allow_hash_href --check_favicon --check_opengraph --check_html --check_img_http --http_status_ignore 429 --url_ignore '#!' --checks_to_ignore '#!' --report_eof_tags --report_invalid_tags --report_mismatched_tags --report_missing_names --report_script_embeds /Users/tommi/tommi.space/\_site # --report_missing_doctype
See HTML Proofer > Configuration for the complete parameters list.
Linux
Vim
!Vim
Pandoc
Exiftool
FFMPEG
git
!git