Watch a file for changes and copy/sync it to a remote host


  • works on Linux and Mac OS
  • install entr
ls -b [file]... | entr -p scp /_ targethost:/destination/folder/


  • works only on Linux
  • it does not work if the file is replaced rather than changed.
  • install inotify-tools
F="filename" eval 'inotifywait -m -e close_write $F | while read E; do echo -e $(date +"%F %T") $E; scp $F root@targethost:/destination/folder/; done;'

Ranger Cheatsheet

ranger is a console file manager with vim key bindings

Most Used Keyboard Shortcuts

ttag toggle
g nnew tab
TABnext tab
qquit tab
d Ddelete
d dcut
y yyank / copy
p ppaste
p opaste overwrite
g hgo home
Sopen shell
ropen with …
d ccount the size
[move up in the parent directory
]move down in the parent directory
``last directory bookmark
z htoggle show hidden files
o rsort reverse
o msort by mtime
o nsort natural / by name
Rreload this directory
SPACEselect under cursor
vinvert selection / select all

Convert to mp3 Using FFMPEG

In this example we will convert m4a audio files to mp3. But you can convert virtually any audio format.

$ mkdir converted
$ for f in *.m4a; do ffmpeg -i "$f" -codec:v copy -codec:a libmp3lame -q:a 2 converted/"${f%.m4a}.mp3"; done;
  • -q:a 2 means LAME’s option -V 2, which gives us a VBR MP3 audio stream with an average stereo bitrate of 170-210 kBit/s. See for more options.
  • make sure you convert to equal or lower quality (it would not make much sense to convert to better quality than the source)

Byobu / Tmux / Screen


Function keys work by default only in byobu.

ctrl-a cF2create new window
ctrl-a pF3previous window
ctrl-a nF4next window
ctrl-a ctrl-aprevious window
F5refresh all status notifications
ctrl-a dF6detach from session / leave
ctrl-a [F7scrollback / search mode
ctrl-a AF8rename current window

Tell byobu to not set the terminal window title


Set the title of your terminal window by running

echo -ne "\033]0;${HOSTNAME%%.*}\007"

This will set your terminal title to the hostname your are on (without domain part). Add this to your $PROMPT_COMMAND to set it automatically with every command you run.

Organize your Photos by Date Using Exiftool

Find all photos without date information

$ exiftool -filename -filemodifydate -createdate -r -if '(not $datetimeoriginal) and $filetype eq "JPEG"' .

Set last created and modified to a specific date

$ find . -name "*.jpg" | while read filename;
exiftool "-AllDates=1986:11:05 12:00:00" "$filename";

Copy of the originals will be created. Remove *.jpg_original if everything went fine or add -overwrite_original parameter.


by one year

$ exiftool "-AllDates+=1:0:0 00:00:00" .

Rename your files to contain the date and time

they will be suffixed with -N if they have the same date and time

$ exiftool '-FileName<DateTimeOriginal' -d "%Y%m%d_%H%M%S%%-c.%%e" *.jpg
$ exiftool '-FileName<DateTimeOriginal' -d "%Y-%m-%d %H.%M.%S%%-c.%%e" *.jpg

Copy your photos in a folder structure organised by datetime

exiftool '-Directory<CreateDate' -d ~/Dropbox/Photos/%Y/%y%m -r .

ReplayGain your music using mp3gain

ReplayGain is the name of a technique invented to achieve the same perceived playback loudness of audio files. Read more on Hydrogenaudio.

Set all files to 92db – this is the most used loudness now-a-days (it’s recommended also in Serato DJ software and most streaming platforms seems to use same value). You might want to use 89db if you are listening on a Hi-Fi system – in this case just ignore the -d 3 option.

The suggested loudness is ~89, so we add 3.

mp3gain -d 3 -c -p -r *.mp3


mp3gain -s r -d 3 -c -p -r *.mp3

-s r this will ignore the replaygain information already stored in the file

-c will ignore clipping warning, use -k to lower the gain to not clip

-p preserve original timestamp of files

-r gain per track (as opposed to per album), it’s good for collections, best of, etc.

recursively apply gain to all your mp3 files

  • it works also for file names with spaces
find . -iname '*.mp3' -print0 | xargs -0 mp3gain -d 3 -c -p -r