sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Install oh-my-zsh via wget
1
sh -c "$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
설정
폰트는 fonts-powerline등 agnoster 테마를 정상적으로 사용할 수 있는 폰트로 사용한다.
테마 설정
1
2
3
4
5
6
7
# vim 에디터로 .zshrc 열기vim ~/.zshrc
# .zshrc 중 ZSH_THEME 부분ZSH_THEME="agnoster"# 수정 후 저장# 이후 적용source ~/.zshrc
플러그인 사용 설정
아래 설치한 플러그인을 사용하기 위해선 .zshrc 파일에 설정해야 한다.
1
2
3
4
5
6
7
8
9
10
11
12
13
# vim 에디터로 .zshrc 열기vim ~/.zshrc
# .zshrc 중 plugins 부분plugins=( ...
zsh-syntax-highlighting
zsh-autosuggestions
fzf
...
)# 수정 후 저장# 이후 적용source ~/.zshrc
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install
# Do you want to enable fuzzy auto-completion? ([y]/n) y# Do you want to enable key bindings? ([y]/n) y# Do you want to update your shell configuration files? ([y]/n) y# Update /home/nine/.bashrc:# - [ -f ~/.fzf.bash ] && source ~/.fzf.bash# + Added# # Update /home/nine/.zshrc:# - [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh# + Added# # Finished. Restart your shell or reload config file.# source ~/.bashrc # bash# source ~/.zshrc # zsh# # Use uninstall script to remove fzf.# # For more information, see: https://github.com/junegunn/fzf
커스텀 설정
사용자명 + 랜덤 이모지 설정
1
2
3
4
5
6
7
8
9
10
11
12
# vim 에디터로 .zshrc 열기vim ~/.zshrc
# .zshrc 최하단에 추가prompt_context(){# Custom (Random emoji)emojis=("🦋""🌈")RAND_EMOJI_N=$(($RANDOM%${#emojis[@]}+1)) prompt_segment black default "Name ${emojis[$RAND_EMOJI_N]} "}# 수정 후 저장# 이후 적용source ~/.zshrc
새로운 줄에서 명령어 시작
경로가 길거나 명령어가 길거나 뭐, 가끔 테마가 깨지는 경우를 대비해 깔끔하게 새로운 라인에서 명령어를 입력할 수 있게 변경
# 테마의 환경 파일 열기vim ~/.oh-my-zsh/themes/agnoster.zsh-theme
# build_prompt 부분을 찾아서 prompt_hg와 prompt_end 사이에 prompt_newline을 추가build_prompt(){RETVAL=$? prompt_status
prompt_virtualenv
prompt_aws
prompt_context
prompt_dir
prompt_git
prompt_bzr
prompt_hg
prompt_newline # 이 위치에 추가한다. prompt_end
}# 아래 내용을 추가한다.prompt_newline(){if[[ -n $CURRENT_BG]];thenecho -n "%{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{%k%F{blue}%}$SEGMENT_SEPARATOR"elseecho -n "%{%k%}"fiecho -n "%{%f%}"CURRENT_BG=''}# 수정 후 저장# 이후 적용source ~/.zshrc
Tmux
터미널 세션을 만들 수 있고 터미널 분할이 가능하다.
세션을 바꿔가며 터미널을 확인할 수 있다.
tmux 명령으로 실행할 때마다 새로운 세션이 생성된다.
1
2
3
4
# tmux 설치sudo apt-get install tmux
# 이후 tmux 실행tmux
이후 tmux의 설정(.tmux.conf)은 세션을 재시작하거나 명령어로 적용할 수 있다.
1
2
3
# prefix + b, :# 명령 모드에서source-file ~/.tmux.conf
Tmux Command
명령어
설명
tmux
새 tmux 세션 시작
tmux ls 또는 tmux list-sessions
실행 중인 tmux 세션 목록 보기
tmux attach-session -t {세션명}
특정 세션에 접근 (세션명에 따라)
tmux attach 또는 tmux a
마지막으로 사용한 tmux 세션에 접근
tmux new -s {세션명}
새로운 tmux 세션을 특정 이름으로 시작
tmux kill-session -t {세션명}
특정 세션 종료 (세션명에 따라)
tmux kill-server
모든 tmux 세션 종료 (서버 종료)
Ctrl + b, d
현재 tmux 세션에서 detach (세션 분리)
Ctrl + b, s
세션 목록 보기 (세션 선택 후 attach 가능)
Ctrl + b, $
현재 세션의 이름 변경 (rename session)
Tmux Shortcuts
Meta 키 M - 일반적으로 Alt 키로 매핑된다. 즉, M-1은 Alt + 1 과 동일하다.
DC는 delete 키를 의미한다.
단축키
설명
C-b C-b
Prefix 키 자체를 입력 (즉, C-b를 두 번 입력)
Prefix C-o
창을 순환 이동 (Rotate through panes)
Prefix C-z
현재 클라이언트 일시 정지 (Suspend the current client)
Prefix Space
다음 레이아웃 선택 (Select next layout)
Prefix !
현재 패널을 새로운 창으로 이동 (Break pane to a new window)
Prefix "
창을 수직으로 분할 (Split window vertically)
Prefix #
모든 붙여넣기 버퍼 목록 표시 (List all paste buffers)
Prefix $
현재 세션 이름 변경 (Rename current session)
Prefix %
창을 수평으로 분할 (Split window horizontally)
Prefix &
현재 창 종료 (Kill current window)
Prefix '
창 번호 입력 후 이동 (Prompt for window index to select)
Prefix (
이전 클라이언트로 전환 (Switch to previous client)
Prefix )
다음 클라이언트로 전환 (Switch to next client)
Prefix ,
현재 창 이름 변경 (Rename current window)
Prefix -
가장 최근 붙여넣기 버퍼 삭제 (Delete the most recent paste buffer)
Prefix .
현재 창 이동 (Move the current window)
Prefix /
키 바인딩 설명 표시 (Describe key binding)
Prefix 0~9
특정 번호의 창 선택 (Select window 0~9)
Prefix :
명령어 입력 프롬프트 (Prompt for a command)
Prefix ;
이전 활성 패널로 이동 (Move to the previously active pane)
Prefix =
붙여넣기 버퍼 선택 (Choose a paste buffer from a list)
Prefix ?
키 바인딩 목록 표시 (List key bindings)
Prefix C
옵션 사용자 지정 (Customize options)
Prefix D
클라이언트 분리 선택 (Choose and detach a client from a list)
Prefix E
패널 크기를 균등하게 조정 (Spread panes out evenly)
Prefix L
마지막 클라이언트로 전환 (Switch to the last client)
Prefix M
선택된 패널 마크 해제 (Clear the marked pane)
Prefix [
복사 모드 진입 (Enter copy mode) -> spacebar 선택, enter 복사 (키가 동작하지 않는 경우 vi 키맵핑 필요할 수 있음)
Prefix ]
최근 붙여넣기 버퍼 붙여넣기 (Paste the most recent paste buffer)
Prefix c
새 창 생성 (Create a new window)
Prefix d
현재 클라이언트 분리 (Detach the current client)
Prefix f
패널 검색 (Search for a pane)
Prefix i
창 정보 표시 (Display window information)
Prefix l
이전 창으로 이동 (Select the previously current window)
Prefix m
현재 패널 마크/마크 해제 (Toggle the marked pane)
Prefix n
다음 창 선택 (Select the next window)
Prefix o
다음 패널 선택 (Select the next pane)
Prefix p
이전 창 선택 (Select the previous window)
Prefix q
패널 번호 표시 (Display pane numbers)
Prefix r
현재 클라이언트 다시 그리기 (Redraw the current client)
Prefix s
세션 목록에서 선택 (Choose a session from a list)
Prefix t
시계 표시 (Show a clock)
Prefix w
창 목록에서 선택 (Choose a window from a list)
Prefix x
활성 패널 종료 (Kill the active pane)
Prefix z
패널 확대/축소 (Zoom the active pane)
Prefix {
현재 패널을 위쪽 패널과 교환 (Swap the active pane with the pane above)
Prefix }
현재 패널을 아래쪽 패널과 교환 (Swap the active pane with the pane below)
Prefix ~
메시지 기록 보기 (Show messages)
Prefix DC (DC = delete)
창의 보이는 부분을 커서가 따라가도록 리셋 (Reset visible part of the window follows the cursor)
Prefix PPage
복사 모드에서 위로 스크롤 (Enter copy mode and scroll up)
Prefix ↑ / ↓ / ← / →
패널 간 이동 (Select pane up/down/left/right)
Prefix M-1 ~ M-5 (M = Alt)
레이아웃 설정 (Set even-horizontal, even-vertical, main-horizontal, main-vertical, tiled layout)
Prefix M-n / M-p
경고가 있는 창으로 이동 (Select next/previous window with an alert)
Prefix M-o
패널을 반대 방향으로 순환 (Rotate through the panes in reverse)
Prefix M-↑ / M-↓ / M-← / M-→
패널 크기 조정 (Resize pane up/down/left/right by 5)
Prefix C-↑ / C-↓ / C-← / C-→
패널 크기 조정 (Resize pane up/down/left/right)
Prefix S-↑ / S-↓ / S-← / S-→
창의 보이는 부분을 이동 (Move the visible part of the window up/down/left/right)
Tmux Plugin Manager
Tmux Plugin Manager (TPM) 설치
1
2
3
4
5
6
7
8
9
10
11
12
13
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
# 사용자의 홈 디렉토리에 `.tmux.conf` 파일을 열거나 생성한다.vim ~/.tmux.conf
# 아래 내용을 입력 후 저장# TPM 설정set -g @plugin 'tmux-plugins/tpm'# tmux에서 마우스 스크롤 활성화set -g mouse on
# TPM을 초기화하는 설정run '~/.tmux/plugins/tpm/tpm'
시스템 리부팅 시 작업하던 Tmux 세션이 날아가는데,
세션을 저장하고 불러올 수 있게 해준다.
플러그인 설정 및 설치
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 사용자의 홈 디렉토리에 `.tmux.conf` 파일을 생성하거나 수정vim ~/.tmux.conf
# 아래 내용을 run '~/.tmux/plugins/tpm/tpm' 명령 위에 추가 후 저장# tmux-resurrect 플러그인 추가set -g @plugin 'tmux-plugins/tmux-resurrect'# 만약 TPM 설치도 정상, .tmux.conf 설정도 정상일 때 결과# [0/0]Installing "tmux-resurrect"# "tmux-resurrect" download success## TMUX environment reloaded.## Done, press ESCAPE to continue.
Key bindings
prefix + Ctrl-s - save
prefix + Ctrl-r - restore
vi 키 맵핑
tmux는 기본적으로 vi 키로 동작하지만 정상적으로 키 입력이 안 되는 경우가 발생할 수 있다.
그럴 땐 직접 vi 키 맵핑으로 동작할 수 있게 설정에 추가하고 적용한다.
문서 하단에 추가하고 설정 적용 커맨드 실행한다.
1
2
3
4
5
6
# 사용자의 홈 디렉토리에 `.tmux.conf` 파일을 생성하거나 수정vim ~/.tmux.conf
# vi 키 바인딩# 복사모드 Termux에서 실행 중인 tmux 세션에서 스페이스바와 Enter 키를 사용하여 해당 줄을 복사set-window-option -g mode-keys vi
📌선택사항
Windows Terminal 설치
MicroSoft Store에서 Windows Terminal을 설치한다.
터미널의 설정에서 기본 프로필, 폰트, 컬러 등을 설정한다.
vim ~/.zshrc
# ZSH_THEME 찾아서 변경ZSH_THEME="powerlevel10k/powerlevel10k"# 변경된 .zshrc 적용source ~/.zshrc
변경된 .zshrc 적용 후 아래와 같이 출력 되면 성공
UTF-8 텍스트 확인
ASCII 문자로 충분했지만 대부분의 오픈 소스들은 거의 최소 UTF-8를 쓰고 있기 때문에 사용하는 폰트가 해당 텍스트를 지원하고 있는지 확인하는 것
PUA(Private Use Area)에 해당하는 글자가 보이는지 확인
PUA는 이름 그대로 사용자 정의 영역이고 UTF-8, UTF-16에서 사용자 개인이 직접 특수 문자를 정의해서 쓸 수 있는 구간.(U+E000 ~ U+F8FF, U+F0000 ~ U+10FFFF)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
This is Powerlevel10k configuration wizard. You are seeing it because you haven't
defined any Powerlevel10k configuration options. It will ask you a few questions and
configure your prompt.
Does this look like a diamond (rotated square)?
reference: https://graphemica.com/%E2%97%86
---> <---
(y) Yes.
(n) No.
(q) Quit and do nothing.
Choice [ynq]:
이후 여러가지 설정을 묻는데 취향에 맞게 설정 후 recommended 옵션으로 마무리한다.
기존에 적용했던 랜덤 임티와 이름 표현도 수정이 필요하다.
~/.p10k.zsh
랜덤 이모지 적용
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# The list of segments shown on the left. Fill it with the most important segments.typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(# =========================[ Line #1 ]=========================# os_icon # os identifier custom_emoji # custom emoji dir # current directory vcs # git status# =========================[ Line #2 ]========================= newline # \n# prompt_char # prompt symbol)# custom emoji envPOWERLEVEL9K_CUSTOM_EMOJI="my_random_emoji"POWERLEVEL9K_CUSTOM_EMOJI_BACKGROUND=0# 배경# custom emoji functionfunction my_random_emoji(){localemojis=("🤌")echo"${emojis[RANDOM % ${#emojis[@]} + 1]}"}
# If directory is too long, shorten some of its segments to the shortest possible unique# prefix. The shortened directory can be tab-completed to the original.# typeset -g POWERLEVEL9K_SHORTEN_STRATEGY=truncate_to_uniquetypeset -g POWERLEVEL9K_SHORTEN_STRATEGY=truncate
# Replace removed segment suffixes with this symbol.# typeset -g POWERLEVEL9K_SHORTEN_DELIMITER=typeset -g POWERLEVEL9K_SHORTEN_DELIMITER=...
# If set to "first" ("last"), remove everything before the first (last) subdirectory that contains# files matching $POWERLEVEL9K_SHORTEN_FOLDER_MARKER. For example, when the current directory is# /foo/bar/git_repo/nested_git_repo/baz, prompt will display git_repo/nested_git_repo/baz (first)# or nested_git_repo/baz (last). This assumes that git_repo and nested_git_repo contain markers# and other directories don't.## Optionally, "first" and "last" can be followed by ":<offset>" where <offset> is an integer.# This moves the truncation point to the right (positive offset) or to the left (negative offset)# relative to the marker. Plain "first" and "last" are equivalent to "first:0" and "last:0"# respectively.typeset -g POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=false# Don't shorten this many last directory segments. They are anchors.typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1# Shorten directory if it's longer than this even if there is space for it. The value can# be either absolute (e.g., '80') or a percentage of terminal width (e.g, '50%'). If empty,# directory will be shortened only when prompt doesn't fit or when other parameters demand it# (see POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS and POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT below).# If set to `0`, directory will always be shortened to its minimum length.typeset -g POWERLEVEL9K_DIR_MAX_LENGTH=80# When `dir` segment is on the last prompt line, try to shorten it enough to leave at least this# many columns for typing commands.typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS=40# When `dir` segment is on the last prompt line, try to shorten it enough to leave at least# COLUMNS * POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT * 0.01 columns for typing commands.typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT=50# If set to true, embed a hyperlink into the directory. Useful for quickly# opening a directory in the file manager simply by clicking the link.# Can also be handy when the directory is shortened, as it allows you to see# the full directory that was used in previous commands.typeset -g POWERLEVEL9K_DIR_HYPERLINK=false
⚙️EndNote
WSL
Windows Sub-system for Linux, 윈도우의 하위 시스템으로 리눅스 사용
Info
개발자는 Windows 컴퓨터에서 동시에 Windows와 Linux의 기능에 액세스할 수 있습니다. WSL(Linux용 Windows 하위 시스템)을 사용하면 개발자가 Linux 배포판(예: Ubuntu, OpenSUSE, Kali, Debian, Arch Linux)을 설치하고 기존 가상 머신 또는 이중 부팅 설정의 오버헤드 없이 Windows에서 직접 Linux 애플리케이션, 유틸리티 및 Bash 명령줄 도구를 사용할 수 있습니다.
Git 자격증명 관련
WSL을 사용할 때 git 명령어 사용 시 username, password를 요구하는 경우가 있다.
온전한 linux가 아니라서 별도 라이브러리를 사용해야 할 수도 있다.
일단, 간단한 방법으로는 windows의 자격증명을 사용하게끔 설정하는 방법이다.
git이 설치되어 있어야 한다.