例如,cd ..<tab>
不会自动完成到cd ../
我在 macOS 上,尝试使用完全空的 .zshrc 运行。
我还尝试添加特定的compdef
for ..
,但这也不起作用。
这个问题可能已经在某个地方有了答案,但很难寻找。
例如,cd ..<tab>
不会自动完成到cd ../
我在 macOS 上,尝试使用完全空的 .zshrc 运行。
我还尝试添加特定的compdef
for ..
,但这也不起作用。
这个问题可能已经在某个地方有了答案,但很难寻找。
我正在使用 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
我想在打开终端(例如 Yakuake、Konsole)时将 tmux 设置为默认值,但在 Dolphin 文件管理器中排除该终端。
我将以下代码片段放入~/.zshrc
if [[ -x "$(command -v tmux)" ]] && [[ -n "${DISPLAY}" ]] && [[ -z "${TMUX}" ]]; then
windowname=$(xdotool getactivewindow getwindowname)
if [[ ${windowname} =~ ".*Yakuake$" ]] || [[ "${windowname}" =~ ".*Konsole$" ]]; then
exec tmux
fi
fi
但该命令xdotool getactivewindow
似乎总是得到错误的活动窗口。所以我写了这个片段来~/.zshrc
进行测试。
xdotool getactivewindow && xdotool getactivewindow getwindowname
sleep 3
xdotool getactivewindow && xdotool getactivewindow getwindowname
但是当通过快捷键ctrl++打开Yakuake时,我得到如下结果。似乎获得了错误的活动窗口名称,即最后一个激活的窗口(在示例中是),它应该是 Yakuake。altYxdotool
sublimetext
94371843
~/.zshrc - Sublime Text
65011722
~ : sleep — Yakuake
当通过KDE等离子或命令行激活Yakuake或Konsole时也有同样的现象。
当终端打开时,如何将 tmux 作为默认启动排除 Dolphin 中的终端?
更新:感谢卡米尔·马乔罗夫斯基的回答,在我的~/.zshrc
.
if [[ -x "$(command -v tmux)" ]] && [[ -n "${DISPLAY}" ]] && [[ -z "${TMUX}" ]]; then
if [[ ! "$(readlink -f /proc/${PPID}/exe)" =~ "dolphin" ]]; then
exec tmux
fi
fi
在powerlevel10k (zsh) 中,分支分隔符的路径可以是三角形或半圆形(图像底部);在 powerline (图像顶部)中,“三角形”也可以分隔文件夹/子文件夹而不是/
,这在 p10k 中可以实现吗?
我使用Meslo LG S,因为它适合 p10k 图标。
编辑:要替换~
为主页图标,请将其添加到.p10k.zsh
typeset -g POWERLEVEL9K_HOME_FOLDER_ABBREVIATION=$'\uF015'
typeset -g POWERLEVEL9K_DIR_CLASSES=()
我正在将脚本从 bash 转换为 zsh,并且已经在输出中苦苦挣扎了好几天。我希望 stdout 和 stderr 都转到控制台和日志文件。我已经尝试了网上能找到的所有方法,但没有任何乐趣。我已经阅读了 zsh 手册的重定向部分,但没有发现任何帮助,尽管我必须承认我不清楚。
以下是我在脚本开头附近尝试过的实验及其结果:
exec 2>&1 | tee -i test.log # everything in console, log created but empty
exec 2>&1 | tee -i > test.log # everything in console, log created but empty
exec 1>>$LOG; exec 2>&1 # everything in log, none in console
exec 2>&1; exec 1>>$LOG # console gets errors only; log stdout only
exec &> >(tee "$LOG") # works in bash, error in zsh
exec > >(tee -i ${LOG?}) 2>&1 # error
exec |& tee $LOG # error
exec > >(tee $LOG) 2>&1 # error
我还尝试了解 zsh 选项 multios,但无法理解它。它应该默认打开,但当我运行时,我在选项列表中找不到它setopt
。当我跑步时也没有setopt multios
。当我运行时unsetopt multios
,我看到了该选项nomultios
,但这似乎没有帮助
我知道已经有人提出并回答了类似的问题,但答案大多在上面的列表中,对我不起作用。
我认为这不相关,但我还设置了一个获取文件描述符 3 的调试日志。它仅适用于以 >&3 结尾的调试输出行。
任何寻找此类解决方案的人请注意:上述 exec 试验是用混乱的 shebang 完成的,并且纠正后的结果有点不同。除了下面 Gairfowl 的解决方案之外,这也有效:
exec > >(tee $LOG) 2>&1
如题。我是 zsh 的用户,我经常阅读这样的帖子:
nix profile install nixpkgs#hello
但我需要为最后一个参数添加引号以避免此错误:
zsh: no matches found: nixpkgs#hello
是否可以只使用上面的命令而不是带有的命令'nixpkgs#hello'
?
我在 Mac 上同时使用 VScode 的内置终端 + 终端 (zsh)。我的印象是他们曾经共享相同的历史,但现在不再了。
理想情况下,我输入的命令会自动附加到我通常位于/Users/<my-user>/.zsh_history
.
有没有一种简单的方法可以配置我的 vscode 终端以从我的 zsh 共享相同的历史记录?
我刚刚安装了 Powerlevel10k,我不得不说我真的很喜欢它。但是,我想将当前目录模块的名称缩短为当前文件夹。
简而言之,我想改变这一点:
~/Documents/Repositories/cool-project
仅此:
~ cool-project
在研究此问题的解决方案时,我遇到了以下设置:
# 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_unique
我怀疑修改此设置是实现我想要的关键,但我不知道有哪些替代设置,SHORTEN_STRATEGY
因为我似乎没有在任何地方找到文档或样式语法。
先感谢您!