我正在使用 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 中有趣的部分是 plugins() 块被注释掉了。如果我取消注释这些插件,但注释掉,
source $ZSH/oh-my-zsh.sh
那么目录堆栈将再次按预期工作。
我尝试过调试,但已经没有主意了。感谢您的时间。
.zshrc 中包含来自常规 cd 命令的不需要的 pushd:
# 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
嘚提供了一个名为的选项AUTO_PUSHD
,其描述man zshoptions
如下:
让 cd 将旧目录推送到目录堆栈上。
oh-my-zsh 可能启用了此选项。因此应该可以通过发出以下命令来禁用该行为
unsetopt AUTO_PUSHD