모든 내용을 그대로 따라지 마세요. 시간이 지나 변경된 내용도 있음. 아래
따라 해보기
내용을 참고하세요.
- 기본 쉘 확인 및 변경
echo $SHELL
- zsh 이 아니면 설치할 수 있는 쉘의 목록을 확인
cat /etc/shells
- 없으면 설치하기
그럴리 없음
기본 유틸리티 설치
brew install git git-delta
기본 내장 git 은 초기 구동시 xcode build tool 과 엮인게 있어서 그런지 매우 느린 현상을 겪고 있음.
brew install bat exa fd fzf gitui lazygit glow lf loc ripgrep xh zoxide
추가로 사용할 유틸리티를 설치합니다. 한 번에 설치되지 않는 경우는 brew tap 을 통해 설치되는 것들이니 brew info 패키지이름
을 통해 확인해주세요.
- 변경하기
혹시라도 다른 쉘을 사용중이라면 변경하자.
chsh -s $(which zsh)
새 탭을 열어 zsh 로그인 할 수 있다.
개인적으로 선호하는 zsh 용 플러그인 매니저입니다.
- 플러그인 시스템 프레임워크 설치
brew install getantibody/tap/antibody
- 탭 어시스트 받기
autoload -U compinit && compinit
- 플러그인 선언
source <(antibody init)
antibody bundle chrissicool/zsh-256color
antibody bundle romkatv/powerlevel10k
antibody bundle zsh-users/zsh-completions
antibody bundle zsh-users/zsh-autosuggestions
antibody bundle zsh-users/zsh-history-substring-search
antibody bundle changyuheng/zsh-interactive-cd
antibody bundle zsh-users/zsh-syntax-highlighting
- 플러그인 환경 설정
powerlevel10k 설정은 별도의 세팅을 통해서 진행할수있음
zhighlighters=(main brackets cursor)
if [ -f ~/.p10k.zsh ]; then
source ~/.p10k.zsh
else
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(time)
POWERLEVEL9K_MODE="nerdfont-complete"
fi
- 명령어 히스토리 버퍼
HISTFILE="${ZDOTDIR:-${HOME}}/.zsh_history"
HISTSIZE=10000
SAVEHIST=10000
HYPHEN_INSENSITIVE='true'
ENABLE_CORRECTION='true'
COMPLETION_WAITING_DOTS='true'
HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='bg=magenta,fg=white,bold'
HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND='bg=red,fg=white,bold'
HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS='i'
- 자동완성 세팅
zstyle ':completion:*:*:*:*:*' menu select
zstyle ':completion:*:matches' group 'yes'
zstyle ':completion:*:options' description 'yes'
zstyle ':completion:*:options' auto-description '%d'
zstyle ':completion:*:corrections' format ' %F{green}-- %d (errors: %e) --%f'
zstyle ':completion:*:descriptions' format ' %F{yellow}-- %d --%f'
zstyle ':completion:*:messages' format ' %F{purple} -- %d --%f'
zstyle ':completion:*:warnings' format ' %F{red}-- no matches found --%f'
zstyle ':completion:*:default' list-prompt '%S%M matches%s'
zstyle ':completion:*' format ' %F{yellow}-- %d --%f'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' verbose yes
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*:*:cd:*' tag-order local-directories directory-stack path-directories
zstyle ':completion:*:*:cd:*:directory-stack' menu yes select
zstyle ':completion:*:-tilde-:*' group-order 'named-directories' 'path-directories' 'expand'
zstyle ':completion:*' squeeze-slashes true
zstyle ':completion::complete:*' use-cache on
zstyle ':completion::complete:*' cache-path "${ZDOTDIR:-${HOME}}/.zcompcache"
zstyle ':completion:*:functions' ignored-patterns '(_*|pre(cmd|exec)|prompt_*)'
zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters
zstyle ':completion:*:manuals' separate-sections true
zstyle ':completion:*:manuals.(^1*)' insert-sections true
zstyle ':completion:*:history-words' stop yes
zstyle ':completion:*:history-words' remove-all-dups yes
zstyle ':completion:*:history-words' list false
zstyle ':completion:*:history-words' menu yes
zstyle ':completion:*:(rm|kill|diff):*' ignore-line other
zstyle ':completion:*:rm:*' file-patterns '*:all-files'
zstyle ':completion:*:(nano|vim|nvim|vi|emacs|e):*' ignored-patterns '*.(wav|mp3|flac|ogg|mp4|avi|mkv|webm|iso|dmg|so|o|a|bin|exe|pcap|7z|zip|tar|gz|bz2|rar|deb|pkg|gzip|pdf|mobi|epub|png|jpeg|jpg|gif)'
- 기타 zsh 설정들
setopt BANG_HIST
setopt EXTENDED_HISTORY
setopt INC_APPEND_HISTORY
setopt SHARE_HISTORY
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_IGNORE_SPACE
setopt HIST_SAVE_NO_DUPS
setopt HIST_VERIFY
setopt ALWAYS_TO_END
setopt AUTO_MENU
setopt AUTO_LIST
setopt PATH_DIRS
unsetopt CASE_GLOB
unsetopt MENU_COMPLETE
- 자주 사용하는 기능을 함수로 선언
function show_terminal_colors() {
for i in {0..255} ; do
printf "\x1b[38;5;${i}mcolour${i}\n"
done
}
function zombie() {
ps aux | awk '{if ($8=="Z") { print $2 }}'
}
function ff() {
find . -type f -iname '*'$@'*' -ls
}
function fday() {
find . -type f -mtime -1
}
function fhour() {
find . -type f -mmin -60
}
function lfcd() {
tmp="$(mktemp)"
lf -last-dir-path="$tmp" "$@"
if [ -f "$tmp" ]; then
dir="$(cat "$tmp")"
rm -f "$tmp"
if [ -d "$dir" ]; then
if [ "$dir" != "$(pwd)" ]; then
cd "$dir"
fi
fi
fi
}
function peco-select-history() {
local tac
tac="tail -r"
BUFFER=$(\history -n 1 | \
eval $tac | \
peco --query "$LBUFFER")
CURSOR=$#BUFFER
#zle clear-screen
}
- git/node/npm 관련 함수
function git_commit_hash() {
if [ -d .git ]; then
git rev-parse HEAD | cut -c -8
fi
}
function npm_install {
if [ -f yarn.lock ]; then
yarn install $@
else
npm install $@
fi
touch ./node_modules/.metadata_never_index
}
function node_environment {
if [ "$1" = "" ]; then
echo "NODE_ENV="$NODE_ENV
else
export NODE_ENV=$1
echo "set NODE_ENV to '$1'"
fi
}
function prompt_my_node_environment {
if [ "$FC_CONFIG_FILE" = "" ]; then
p10k segment -f blue -b white -t $NODE_ENV
else
p10k segment -f blue -b white -t "$NODE_ENV!custom"
fi
}
- 단축키 할당
zle -N peco-select-history
zle -N edit-command-line
bindkey -e
bindkey '\ew' kill-region
bindkey -s '\el' "ls\n"
bindkey '^r' history-incremental-search-backward
bindkey "${terminfo[kcuu1]}" history-substring-search-up
bindkey "${terminfo[kcud1]}" history-substring-search-down
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
bindkey '^P' history-substring-search-up
bindkey '^N' history-substring-search-down
# pageUp, pageDown, Up, Down key
bindkey "^[[5~" up-line-or-history # page up
bindkey "^[[6~" down-line-or-history # page down
bindkey '^[[A' up-line-or-search # up
bindkey '^[[B' down-line-or-search # down
bindkey "^[[H" beginning-of-line
bindkey "^[[1~" beginning-of-line # home
bindkey "^[OH" beginning-of-line
bindkey "^[[4~" end-of-line # end
bindkey "^[OF" end-of-line
bindkey ' ' magic-space
# bindkey "^F" forward-word
# bindkey "^B" backward-word
bindkey '^[[Z' reverse-menu-complete
bindkey '^?' backward-delete-char
bindkey "^[[3~" delete-char
bindkey "^[3;5~" delete-char
bindkey "\e[3~" delete-char
# command line edit
bindkey '^xe' edit-command-line
bindkey '^x^e' edit-command-line
if [ -e ~/.fzf.zsh ]; then
source ~/.fzf.zsh
else
bindkey '^r' peco-select-history
fi
if [ -e /usr/local/bin/lf ]; then
bindkey -s '^o' 'lfcd\n'
fi
- 앨리어스
alias b='brew'
alias g='git'
alias hist='history'
alias ls='exa --group-directories-first'
alias la='ls -ld .*'
alias lt='ls -ls modified'
alias l='ls -lah'
alias ll='ls -lh'
alias ld='ls -d */'
alias cat='bat'
alias dif='delta'
- 기타 환경 설정
ulimit -n 8192
- zoxide
if [[ -x /usr/bin/zoxide ]] || [[ -x /usr/local/bin/zoxide ]]; then
eval "$(zoxide init zsh)"
elif [[ -x /usr/bin/fasd ]] || [[ -x /usr/local/bin/fasd ]]; then
eval "$(fasd --init auto)"
fi
- fzf
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
- 추가 alias
alias myip="dig +short myip.opendns.com @resolver1.opendns.com"
alias ipx="ifconfig -a | perl -nle'/(\d+\.\d+\.\d+\.\d+)/ && print $1' | awk '{\$1=\$1;print}'"
alias ssh="ssh -A"
alias ..="cd .."
alias ...="cd ../.."
alias mcd='(){ mkdir -p $1 && cd $1 ;}'
alias npmc=npm-check
alias npmi=npm_install
alias cpkg="cat package.json"
alias npkg=cpkg
alias gui="gitui"
alias lg="lazygit"
alias op="open ."
alias ns='npm start'
alias nr='npm run'
alias nd='node-dev --no-notify'
alias ne=node_environment
alias dbg-on="export DEBUG='fc:*,knex:query,knex:bindings'"
alias dbg-off="export DEBUG=''"
alias custom-on="export FC_CONFIG_FILE=~/.fc/custom_env.js"
alias custom-off="export FC_CONFIG_FILE=''"
- NodeJS 16 버전 고정시 사용할 path
export PATH="/usr/local/opt/node@16/bin:$PATH"
- 로컬 개발 환경 선언
ne local
- 디버그 환경 선언
export DEBUG='fc:*'
echo "set DEBUG to fc:*"
아래 첨부된 파일 참고
- 플러그인 업데이트 한 번!
antibody update
- 터미널용 폰트 설치
- 새 창을 띄워 본다!