Useful bash

Convert all wav in dir to mp3

for i in *.wav; do lame -b 320 "$i"; done

Get IP on macos

ipconfig getifaddr en0

Convert copied md to html

You can use docx also
pbpaste | pandoc -f markdown -t html | pbcopy
You can also use it as an alias in your bash profile like so:
alias md="pbpaste | pandoc -f markdown -t html | pbcopy; echo 'Conversion done.'"
Now, just type md to swap the Markdown in your clipboard for HTML.

Update all formulas

brew upgrade

Move all file inside directory to upper dir

from this stack exchange
mv * .[^.]* ..
Explanation: the mv command moves files and directories. The last argument to mv is the target (in this case the directory one step "up" in the tree, ..). The arguments before that are the source files and directories. The asterisk (*) is a wildcard which matches all files which do not start with a dot. Files that start with a dot (dotfiles) are "hidden". They are matched using the pattern .[^.]*(see edit below)

Why .[^.]* instead of .* ?
The pattern .* also matches . and ... Since you don't want to (and cannot) move those, it's better to use a pattern which matches any filename starting with a dot except those two. The pattern .[^.]* does just that: it matches any filename (1) starting with a dot (2) followed by a character which is not a dot (3) followed by zero or more arbitrary characters.

Hide File in MacOS

chflags hidden [file_name] #use nohidden to revert

Compress Gif

gifsicle -O3 --colors 256 -i in.gif -o out.gif
convert -loop 0 input ouptput

Fuzzy search

Using the fzf plugin use ** + tab in a command to open a search bar.

Create symbolic link

ln -s source destination

Dithering

Using magick
-dither FloySteinberg *or* Riemersma
OR
-ordered-dither [map]
list of maps :
- threshold   1x1   Threshold 1x1 (non-dither)
- checks      2x1   Checkerboard 2x1 (dither)
- o2x2        2x2   Ordered 2x2 (dispersed)
- o3x3        3x3   Ordered 3x3 (dispersed)
- o4x4        4x4   Ordered 4x4 (dispersed)
- o8x8        8x8   Ordered 8x8 (dispersed)
- h4x4a       4x1   Halftone 4x4 (angled)
- h6x6a       6x1   Halftone 6x6 (angled)
- h8x8a       8x1   Halftone 8x8 (angled)
- h4x4o             Halftone 4x4 (orthogonal)
- h6x6o             Halftone 6x6 (orthogonal)
- h8x8o             Halftone 8x8 (orthogonal)
- h16x16o           Halftone 16x16 (orthogonal)
- c5x5b       c5x5  Circles 5x5 (black)
- c5x5w             Circles 5x5 (white)
- c6x6b       c6x6  Circles 6x6 (black)
- c6x6w             Circles 6x6 (white)
- c7x7b       c7x7  Circles 7x7 (black)
- c7x7w             Circles 7x7 (white)
magick input.png -resize -dither FloydSteinberg
For a black and white dither, put the image in grey before dithering with -colorspace Grey
// maybe limit the color number to be sure -colors 2
After dithering add -threshold 50%

easy manipulation of color space

Use the magick command with the +level-colors flag.
+level-colors [replace black with], [replace white with]
# exemple
+level-colors green, orchid2
List of all imagemagick colors can found on this webpage
- home -