gpg / ssh


gpg --list-secret-keys --keyid-format LONG gpg --import




fish tmux new -s named-session tmux -a named-session

Ctrl + b I to install/restart Ctrl + b y to yank Ctrl + b o to switch panes Ctrl + b % for a vertical pane Ctrl + b " for a horizontal pane

vim bindings work for navigation. | and w for splits




  • :sp and :vsp for splits
  • Ctrl+w for focus shifting, max/min with _ and =

  • ':set spell' activates vim spellchecker. Use ']s' and '[s' to move between mistakes, 'zg' adds to the dictionary, 'z=' suggests correctly spelled words

  • check my .vimrc and here for more


```fish chsh -s /usr/local/bin/fish

edit /etc/shells I think

chsh -s /bin/bash

curl --create-dirs -sLo ~/.config/fish/functions/ ```

Once nice thing about Fish is a web-based configuration. Run fish_config to start the web client.

get your fonts

Consider further...


``` set --universal fish_user_paths $fish_user_path ~/bin/

Define alias in shell

alias rmi "rm -i"

Define alias in config file

alias rmi="rm -i"

This is equivalent to entering the following function:

function rmi rm -i $argv end

Then, to save it across terminal sessions:

funcsave rmi ```



install brews

brew install bundle brew install $(< Brewfile )


brew cask install font-source-code-pro-for-powerline brew cask install iterm2


echo /usr/local/bin/fish >> /etc/shells chsh -s /usr/local/bin/fish

curl --create-dirs -sLo ~/.config/fish/functions/ ```



also consider dnsmasq




apm list --installed --bare > ~/.atom/package.list


apm install --packages-file ~/.atom/package.list



To encrypt/decrypt... Cmd+Shift+P, bombe

fish ag -A sentry ~/notes/projects/*.md --no-numbers


  • 'htop' instead of 'top'
  • ps aux | egrep '[t]erminal
  • Pipe any command over 'column -t' to nicely align the columns
  • 'file' gives information about a file, as image dimensions or text encoding
  • watch
  • 'echo | at midnight' starts a command at the specified time
  • 'ranger' is a nice console file manager for vi fans
  • linux: Use 'apt-file' to see which package provides that file you're missing
  • if you liked the 'psgrep' alias, check 'pgrep' as it is far more powerful
  • learn to use 'pushd' to save time navigating folders ( is better though)
  • 'dict' is a commandline dictionary
  • Learn to use 'find' and 'locate' to look for files
  • Compile your own version of 'screen' from the git sources. Most versions have a slow scrolling on a vertical split or even no vertical split at all
  • 'trash-cli' sends files to the trash instead of deleting them forever. Be very careful with 'rm' or maybe make a wrapper to avoid deleting '' by accident (e.g. you want to type 'rm tmp' but type 'rm tmp *')
  • 'sort | uniq' to check for duplicate lines
  • Google 'magic sysrq' and learn how to bring you machine back from the dead
  • 'diff --side-by-side fileA.txt fileB.txt | pager' to see a nice diff
  • '' remembers your most used folders and is an incredible substitute to browse directories by name instead of 'cd'
  • '' is a fantastic solution to upload by commandline via Dropbox's API if you can't use the official client
  • never run 'chmod o+x * -R', capitalize the X to avoid executable files. If you want only executable folders: 'find . -type d -exec chmod g+x {} \;'
  • 'xargs' gets its input from a pipe and runs some command for each argument
  • run jobs in parallel easily: ls *.png | parallel -j4 convert {} {.}.jpg



DJANGO_DOCKER_ID=$( docker service ls | grep sportshi_dev_django | awk '{print $1}' ) echo $DJANGO_DOCKER_ID docker exec -i $DJANGO_DOCKER_ID bash

git commit --amend --reset-author --no-edit


``` youtube-dl youtube-dl --extract-audio --audio-format mp3 -o "%(title)s.%(ext)s" youtube-dl --extract-audio --audio-format mp3 -o "%(title)s.%(ext)s"

youtube-dl --extract-audio --audio-format mp3 -o "%(title)s.%(ext)s" youtube-dl --extract-audio --audio-format mp3 -o "%(title)s.%(ext)s" ```

rsync -avPz -e "ssh -p 8000" [email protected]:/media/munich/torrents/Jap* ./


gifsicle --delay=10 --loop *.gif > anim.gif convert -delay 10 -loop 0 *.png animation.gif


convert *.gif -gravity south -splice 0x111 -shave 0x111 -resize 400x400 -set delay 300 output.gif convert *.png -gravity south -splice 0x111 -shave 0x111 -resize 400x400 converted.png montage *.gif -mode concatenate -tile 1x2 -resize 400x400 output.gif

convert -size 320x90 canvas:none -stroke snow4 -size 1x90 -tile gradient:white-snow4 \ -draw 'roundrectangle 16, 5, 304, 85 20,40' +tile -fill snow \ -draw 'roundrectangle 264, 5, 304, 85 20,40' -tile gradient:chartreuse-green \ -draw 'roundrectangle 16, 5, 180, 85 20,40' -tile gradient:chartreuse1-chartreuse3 \ -draw 'roundrectangle 140, 5, 180, 85 20,40' +tile -fill none \ -draw 'roundrectangle 264, 5, 304, 85 20,40' -strokewidth 2 \ -draw 'roundrectangle 16, 5, 304, 85 20,40' \( +clone -background snow4 \ -shadow 80x3+3+3 \) +swap -background none -layers merge \( +size -font Arial \ -pointsize 90 -strokewidth 1 -fill red label:'50 %' -trim +repage \( +clone \ -background firebrick3 -shadow 80x3+3+3 \) +swap -background none -layers merge \) \ -insert 0 -gravity center -append -background white -gravity center -extent 320x200 \ cylinder_shaded.png



sips -Z 640 *.jpg sips -Z 800 *.jpg sips -Z 1600 *.JPG

terminal in osx

  • Copy is Ctrl + U
  • Paste is Ctrl + Y
  • Move by words via option+ left or right



jpg to ascii text

perl s// recursive

perl perl -p -i -e 's/\white\-text//g' `grep -ril white-text *`


bash convert -adjoin -page A4 *.jpeg multipage.pdf


largest 20

bash du -xk | sort -n | tail -20

bash du -h . | grep ^[0-9.][0-9.]G du -h . | grep ^[5-9][0-9][0-9.]M

name and line search and delete

find ./ -name '*.php' -exec sed -i '/three\_by\_three/d' {} \;

move files from subdirectory into current folder

find ./ -type f -exec mv {} ./ \; # Move all files into X find ./ -depth -type d -exec rmdir {} \; # Remove all subdirectories of X



prompt mysql (\d)-(\r:\m:\s)>;

CREATE USER 'stampede'@'%' IDENTIFIED BY 'password'; grant all on stampede\_%.* to stampede@%; \G ``` Retrieved from


  • In bash, 'ctrl-r' searches your command history as you type
  • Input from the commandline as if it were a file by replacing 'command <' with 'command <<< "some input text"'
  • '^' is a sed-like operator to replace chars from last command 'ls docs; ^docs^web^' is equal to 'ls web'. The second argument can be empty.
  • '!!:n' selects the nth argument of the last command, and '!$' the last arg 'ls file1 file2 file3; cat !!:1-2' shows all files and cats only 1 and 2
  • More in-line substitutions:
  • 'nohup ./long_script &' to leave stuff in background even if you logout
  • 'cd -' change to the previous directory you were working on
  • 'ctrl-x ctrl-e' opens an editor to work with long or complex command lines
  • Use traps for cleaning up bash scripts on exit
  • 'shopt -s cdspell' automatically fixes your 'cd folder' spelling mistakes
  • Add 'set editing-mode vi' in your ~/.inputrc to use the vi keybindings for bash and all readline-enabled applications (python, mysql, etc)



check ports

lsof -i -n -P | grep trans

  • Some tools to monitor network connections and bandwith:
    • 'lsof -i' monitors network connections in real time
    • 'iftop' shows bandwith usage per connection
    • 'nethogs' shows the bandwith usage per process

cf. ssh bridging

  • 'ssh -R 12345:localhost:22 "sleep 1000; exit"' forwards's port 12345 to your local ssh port, even if you machine is not externally visible on the net. Now you can 'ssh localhost -p 12345' from and you will log into your machine.
  • 'socat TCP4-LISTEN:1234,fork TCP4:' forwards your port 1234 to another machine's port 22. Very useful for quick NAT redirection.
  • Configure postfix to use your personal Gmail account as SMTP: Now you can send emails from the command line. 'echo "Hello, User!" | mail [email protected]'


  • Don't know where to start? SMB is usually better than NFS for most cases. 'sshfs_mount' is not really stable, any network failure will be troublesome
  • 'python -m SimpleHTTPServer 8080' shares all the files in the current folder over HTTP, port 8080
  • 'sleep' avoids getting kicked out from for inactivity
  • Use this trick on .ssh/config to directly access 'host2' which is on a private network, and must be accessed by ssh-ing into 'host1' first

Host host2 ProxyCommand ssh -T host1 'nc %h %p' HostName host2



sudo diskutil unmountDisk force /Volumes/Chris\ Macbook\ Air-1/ sudo diskutil unmountDisk force /Volumes/Chris\ Macbook\ Air/ tmutil status tmutil destinationinfo sudo tmutil startbackup ssh -Y -L 8001:localhost:548 [email protected] -p 8000; tmutil startbackup


``` screen -a screen -list echo $TERM

Ctrl+a c create Ctrl+a n next Ctrl+a d detach Ctrl+a m monitor Ctrl+a k kill Ctrl+a h log Ctrl+a x lock screen -r ```