macOS tips and tricks

macOS tips and tricks

macOS commands

# on bash / zsh shell
du -hsx .[^.]* | grep vscode

sam@SamsMacBookPro ~ % du -hsx .[^.]* | grep vscode
1.5G	.vscode

The du utility displays the file system block usage for each file argument and for each directory in the file hierarchy rooted in each directory argument. If no file is specified, the block usage of the hierarchy rooted in the current directory is displayed.

du -hsx .[^.]* lists the disk usage of all hidden files and directories in the current directory (excluding . and ..), with a human-readable summary. | grep vscode filters the output to show only lines containing vscode.

kill audio service and restart audio

After a while, the audio service will restart automatically.

sudo kill -9 `ps ax|grep 'coreaudio[a-z]' | awk '{print $1}'`
# or
sudo pkill coreaudiod

Close non-responding firefox using macOS Script from terminal

osascript -e 'quit app "Firefox"'