oh-my-zsh를 사용하고 있습니다. 활성화된 경우:
source $ZSH/oh-my-zsh.sh
이 cd
명령은 모든 것에 대해 pushd처럼 작동합니다.
~
➜ dirsv
0 ~
~
➜ cd Projects
~/Projects
➜ dirsv
0 ~/Projects
1 ~
~/Projects
➜ cd Test
~/Projects/Test
➜ dirsv
0 ~/Projects/Test
1 ~/Projects
2 ~
~/Projects/Test
➜ cd ~
~
➜ dirsv
0 ~
1 ~/Projects/Test
2 ~/Projects
dirsv는 내 별칭입니다.
alias dirsv="dirs -v"
내 .zshrc의 흥미로운 부분은 플러그인() 블록이 주석 처리되어 있다는 것입니다. 해당 플러그인의 주석 처리를 제거했지만 주석 처리
source $ZSH/oh-my-zsh.sh
하면 디렉터리 스택이 다시 예상대로 작동합니다.
디버깅을 시도했지만 아이디어가 부족했습니다. 시간 내 줘서 고마워.
일반 cd 명령에서 원치 않는 pushd가 포함된 .zshrc:
# If you come from bash you might have to change your $PATH.
export PATH=$HOME/bin:/usr/local/bin:$PATH
export PATH=$HOME/.local/bin:$PATH
export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
# Path to doom emacs
export PATH=$HOME/.emacs.d/bin/:$PATH
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
# SSH key management for servers
# Start the ssh-agent if it is not already running
if ! pgrep -u "$USER" ssh-agent > /dev/null; then
eval "$(ssh-agent -s)"
fi
# Add keys to the ssh-agent if it doesn't have them already
if [[ "$(ssh-add -l)" == "The agent has no identities." ]]; then
ssh-add ~/.ssh/id_ed25519 > /dev/null 2>&1
fi
# Dirs/pushd/popd aliases
alias dirsv="dirs -v"
alias dirsp="dirs -p"
alias dirsc="dirs -c"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
# ZSH_THEME="robbyrussell"
# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in $ZSH/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"
# Uncomment one of the following lines to change the auto-update behavior
# zstyle ':omz:update' mode disabled # disable automatic updates
# zstyle ':omz:update' mode auto # update automatically without asking
# zstyle ':omz:update' mode reminder # just remind me to update when it's time
# Uncomment the following line to change how often to auto-update (in days).
# zstyle ':omz:update' frequency 13
# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS="true"
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
# You can also set it to another string to have that shown instead of the default red dots.
# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f"
# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765)
COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
# fast-syntax-highlighting
# plugins=(git aliases zsh-vi-mode asdf zsh-autosuggestions zsh-syntax-highlighting zsh-autocomplete)
# possibly add zsh-vi-mode
# Additional configuration for autosuggestions
# ZSH_AUTOSUGGEST_STRATEGY=(history completion)
# ZSH_AUTOSUGGEST_USE_ASYNC=true
# Accept autosuggestion one word at a time
bindkey -M vicmd '^L' vi-forward-word
bindkey -M viins '^L' vi-forward-word
#
source $ZSH/oh-my-zsh.sh
# User configuration
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
export LANG=en_US.UTF-8
export NVIM_APPNAME="nvim-Kickstart"
#vv() {
# # Assumes all configs exist in directories named ~/.config/nvim-*
# local config=$(fd --max-depth 1 --glob 'nvim-*' ~/.config | fzf --prompt="Neovim Configs > " --height=~50% --layout=reverse --border --exit-0)
# # If I exit fzf without selecting a config, don't open Neovim
# [[ -z $config ]] && echo "No config selected" && return
# # Open Neovim with the selected config
# NVIM_APPNAME=$(basename $config) nvim
#}
# export PATH=$PATH:$HOME/CompiledPrograms/nvim-linux64/bin/
# alias nvim="~/CompiledPrograms/nvim-linux64/bin/nvim"
# Preferred editor for local and remote sessions
if [[ -n $SSH_CONNECTION ]]; then
export EDITOR='nvim'
else
export EDITOR='nvim'
fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
# alias ranger=". ranger"
fpath+=${ZDOTDIR:-~}/.zsh_functions
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
eval "$(starship init zsh)"
# . ~/.asdf/plugins/golang/set-env.zsh
export ASDF_GOLANG_MOD_VERSION_ENABLED=true
export PATH=$PATH:/home/doom/.go/bin
export GOPATH=/home/doom/go
export PATH=$PATH:/home/doom/go/bin
# export PATH=$PATH:/home/doom/Programs/zig/zig-linux-x86_64-0.12.0-dev.1344+37295696e/zig
# alias zig=/home/doom/Programs/zig/zig-linux-x86_64-0.12.0-dev.1344+37295696e/zig
# if command -v zoxide > /dev/null; then
# eval "$(zoxide init zsh)"
# fi
# Source the Lazyman shell initialization for aliases and nvims selector
# shellcheck source=.config/nvim-Lazyman/.lazymanrc
[ -f ~/.config/nvim-Lazyman/.lazymanrc ] && source ~/.config/nvim-Lazyman/.lazymanrc
# Source the Lazyman .nvimsbind for nvims key binding
# shellcheck source=.config/nvim-Lazyman/.nvimsbind
[ -f ~/.config/nvim-Lazyman/.nvimsbind ] && source ~/.config/nvim-Lazyman/.nvimsbind
# Luarocks bin path
[ -d ${HOME}/.luarocks/bin ] && {
export PATH="${HOME}/.luarocks/bin${PATH:+:${PATH}}"
}
# Bob neovim version manager path
[ -d ${HOME}/.local/share/bob/nvim-bin ] && {
export PATH="${HOME}/.local/share/bob/nvim-bin${PATH:+:${PATH}}"
}
# Zoxide
# eval "$(zoxide init --cmd cd zsh)"
# Atuin command history manager
# eval "$(atuin init zsh)"
# Alias to start kmonad and store its PID in an environment variable
alias km='kmonad /home/doom/.config/kmonad/first.kbd & export KMONAD_PID=$!'
# Alias to kill kmonad using the stored PID
alias kmd='kill -SIGINT $KMONAD_PID'
[ -f "/home/doom/.ghcup/env" ] && . "/home/doom/.ghcup/env" # ghcup-env
답변1
zshAUTO_PUSHD
다음과 같이 설명 된 옵션을 제공합니다 man zshoptions
.
cd가 이전 디렉토리를 디렉토리 스택에 푸시하도록 합니다.
아마도 oh-my-zsh가 이 옵션을 활성화할 것입니다. 따라서 다음을 발행하여 동작을 비활성화하는 것이 가능해야 합니다.
unsetopt AUTO_PUSHD