Set default node version with nvm

  • 2020-2-27

TL;DR

1
2
〉nvm alias deault 12.13
deault -> 12.13 (-> v12.13.0)

VIM Advanced: Visual Block Mode and Increas Number under cursor

  • 2020-2-17

We can use Ctrl + Q to enter Visual Block Mode, which is really awesome! Another tip for using VIM is Ctrl + A to increase number under the cursor

tmux: Five shortcuts for session management

  • 2020-2-12
  1. prefix + s show all sessions
  2. prefix + d detach dession
  3. prefix + $ rename session
  4. prefix + ( move to previous session
  5. prefix + ) move to next session

tmux: rename session (3 ways)

  • 2020-2-12

Using Shortcut

prefix + $ rename current session

Using tmux comand

1
:rename-sessin [-t current-name] [new-name]

Using shell command

1
tmux rename-sessin [-t current-name] [new-name]

Note: The second way and the third way are actually the same.

Change Mac's system volume via commands

  • 2020-2-12
1
2
sudo osascript -e "set Volume 10" # the maximum
sudo osascript -e "set Volume 0" # mute

Note: We cam set the value between 0 and 10.

tmux: list all sessions

  • 2020-2-12
1
tmux ls # ls all active sessions

tmux ls is actually a short form of tmux list-sessions. Compared to list-sessions, ls is much shorter so I recommend using tmux ls always.

Remove matching from a string in bash

  • 2020-2-12
1
2
3
output="_post/README.md"
file_name=${output#*_posts/} # will remove _post/
echo $file_name # README.md

tmux detach current session

  • 2020-2-12

prefix + C-D detach current session

Check if a string contains a substring in bash

  • 2020-2-10
1
2
3
4
string='My long string'
if [[ $string == *"My long"* ]]; then
echo "It's there!"
fi

Ref: How to check if a string contains a substring in bash

Reloading tmux config

  • 2020-2-10
1
tmux source-file ~/.tmux.conf