Mac Notes
This blog illustrates some notes on using my Mac (model was released in mid 2015, OS is Catalina 10.15).
# Clean Unused Homebrew Dependencies
Like apt-get autoremove
in Ubuntu, I have too many unused homebrew dependencies and want to clean them.
brew bundle dump && brew bundle --force cleanup
# Accented Chars vs. Key Repeat
Mac enables users to hold down a letter key and show accented or special chars.
To enable pop-up and disable key repeat, could set ApplePressAndHoldEnabled
to true
:
defaults write -g ApplePressAndHoldEnabled -bool true
However, as I used Vim
(commands and config) more and more, I see popping up the accented chars less useful.
To disable pop-up and enable key repeat, could set ApplePressAndHoldEnabled
to false
:
defaults write -g ApplePressAndHoldEnabled -bool false
# German Key Combs
Happy ending? Not yet! I recently started learning German and had to find some workaround to type the following chars and symbols (using US keyboard layout).
The German letters:
ä
:Option u
+a
ö
:Option u
+o
ü
:Option u
+u
ß
:Option s
The lower and upper quotes:
„
:Option Shift w
”
:Option Shift [
The Euro symbol:
€
:Option Shift 2
Note that I actually searched online and saw other key combs, but don't work.
# Add Input Source
Another way to guarantee typing the correct German chars, or any language's chars is to use the corresponding input source. This could be done on Mac by: System Preferences
Keyboard
Input Souces
{another language}.
# Further
Please see this article for more details (opens new window) on keyboard viewer, quotes, ellipsis, and IA writer.
# Terminal Caveats
Following are some common caveats for Unix terminal.
# Change Root Password
sudo passwd root
# Terminal Proxy w/ Socks5
It's fairly easy to use a socks5 proxy in browser, but how to use it in terminal, especially when downloading from GitHub is super slow in China? From this article (opens new window) I made the following terminal proxy settings.
In sock5 proxy app set:
- Local Socks5 Listen Address 127.0.0.1
- Local Socks5 Port 1086
- Connection Timeout 60
Then in sh
config file (.bashrc
for Bash
):
# set/unset proxy in terminal
alias setproxy="export ALL_PROXY=socks5://127.0.0.1:1086"
alias unsetproxy="set -e ALL_PROXY"
# set/unset proxy just for Git
alias agent="git config --global http.proxy socks5://127.0.0.1:1086;git config --global https.proxy socks5://127.0.0.1:1086;git config --global http.sslVerify false"
alias unagent="git config --global --unset http.proxy;git config --global --unset https.proxy"
2
3
4
5
6
7
# Disable Proxy for Development Server
SET NO_PROXY=localhost
yarn start # or `npm run start`
2
# Mute/Unmute Startup Chime
# mute
sudo nvram StartupMute=%01
# unmute
sudo nvram StartupMute=%00
2
3
4
# Fish Set Path
# set path
set PATH <newdir> $PATH
2
# nohup
not Hang Up
From here (opens new window) I see:
shopt | grep hupon
# Check Disk Space
How to check free disk space in Linux (opens new window)
# Search for some Pattern in a Directory
Search for some Pattern in a Directory (opens new window)
# Why a Process is Killed
dmesg -T | egrep -i 'killed process'
# Delete a Folder Quickly
perl -e 'for(<*>){((stat)[9]<(unlink))}'
# Folder Sizes under Current Directory in Descending Order
du -sch * .[!.]* | sort -rh
# Change Priority of Scheduled Job
Whenever any process is started in Linux, it is assigned a priority level of 0 by default. Linux Kernel automatically schedules the process and allocates CPU time accordingly for each process.
However, if we want to define the priority level of a process while launching it, we can do so using the nice command utility. If we want to define the priority level of a running process, we can use the renice command utility.
The priority level of a process is called as nice value of the process. In Linux, this nice value can range from to .
TODO: merge this file w/ shell.md