.zshrc 구성, 순서가 중요합니까?

.zshrc 구성, 순서가 중요합니까?

이제 zsh가 Mac의 기본 터미널이므로 .bashrc 기본 설정을 .zshrc에 복사해 보기로 결정했습니다.

필요한 것은 이미 대부분 가지고 있지만 추가해야 할 것이 몇 가지 있습니다. 저는 .zshrc 파일을 만드는 것에 대해 아무것도 몰랐기 때문에 구글에서 검색을 많이 했습니다.

나는 이것을 알아냈지만 그것을 더 깔끔한 것으로 정리하기 전에 순서가 중요합니까?

죄송합니다. 정말 엉망입니다.

#################
# Output Prompt #
#################
NEWLINE=$'\n'
PROMPT="%F{cyan}%n%f@%F{green}%m%f %F{011}%~%f \$vcs_info_msg_0_ ${NEWLINE}%% "
# RPROMPT=\$vcs_info_msg_0_

###########
# ALIASES #
###########
alias ls='ls -GFh'

# TODO: DO MORE RESEARCH ON THESE
# alias l='colorls --group-directories-first --almost-all'
# alias ll='colorls --group-directories-first --almost-all --long' # detailed list view

# case insensitive path-completion from - https://scriptingosx.com/2019/07/moving-to-zsh-part-5-completions/
# zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*'

# partial completion suggestions - from https://scriptingosx.com/2019/07/moving-to-zsh-part-5-completions/
# zstyle ':completion:*' list-suffixes
# zstyle ':completion:*' expand prefix suffix
# E-TODO

export LSCOLORS=gxfxbxdxcxegedabagacad


# The following lines were added by compinstall

zstyle ':completion:*' completer _complete _ignored _approximate
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' matcher-list 'm:{[:lower:]}={[:upper:]} m:{[:lower:][:upper:]}={[:upper:][:lower:]}'



zstyle :compinstall filename '/Users/ryan/.zshrc'

autoload -Uz compinit
compinit
# End of lines added by compinstall

autoload -Uz chpwd_recent_dirs cdr add-zsh-hook
add-zsh-hook chpwd chpwd_recent_dirs

zstyle ':completion:*:*:cdr:*:*' menu selection

autoload -Uz vcs_info
precmd_vcs_info() { vcs_info }
precmd_functions+=( precmd_vcs_info )
setopt prompt_subst
setopt HIST_IGNORE_DUPS # Prevents duplicate commands from being saved the command line history
setopt HIST_IGNORE_SPACE # Remove command lines from the history when the first character is a space
setopt HIST_REDUCE_BLANKS # Remove superfolus blanks from each command being added to the history list

zstyle ':vcs_info:git:*' formats '%F{196}(%b)%f'
zstyle ':vcs_info:*' enable git

답변1

상황에 따라 다르며 때로는 위에서 설명한 Devon을 좋아하지만 서로 관련이 없으면 중요하지 않습니다. 예를 들어, .zshrc에서 사용되지 않거나 .zshrc의 어떤 항목에도 의존하지 않는 일련의 별칭을 정의하는 경우 원하는 곳에 배치할 수 있습니다. 터미널에 일종의 출력을 제공하는 경우 출력은 .zshrc 파일에 넣은 순서대로 나타납니다.

답변2

.zshrczsh는 마치 터미널에 입력한 것처럼 내부에서 명령을 실행합니다 . 순서는 중요합니다. 예를 들어 변수를 정의하기 전에는 사용할 수 없습니다.

관련 정보