gpt4 book ai didi

linux - ZSH 不使用 "sudo -s"加载我的 prezto 配置文件

转载 作者:太空宇宙 更新时间:2023-11-04 13:00:09 24 4
gpt4 key购买 nike

我像往常一样从主目录安装了 prezto 并配置了我最喜欢的提示符 (bigfade)。

当我使用我当前的用户帐户登录时,它会起作用。

但是当我让 sudo -s 成为 root 时,我的配置文件没有像在其他系统中那样加载。我到处查看,但没有看到任何东西,我的 /etc/zsh/zshrc 文件配置良好,如您所见。

所附图片显示了我的 shell 的行为

enter image description here

而txt文件就是我的/etc/zsh/zshrc文件

# /etc/zsh/zshrc: system-wide .zshrc file for zsh(1).
#
# This file is sourced only for interactive shells. It
# should contain commands to set up aliases, functions,
# options, key bindings, etc.
#
# Global Order: zshenv, zprofile, zshrc, zlogin

READNULLCMD=${PAGER:-/usr/bin/pager}

# An array to note missing features to ease diagnosis in case of problems.
typeset -ga debian_missing_features

if [[ -z "$DEBIAN_PREVENT_KEYBOARD_CHANGES" ]] &&
[[ "$TERM" != 'emacs' ]]
then

typeset -A key
key=(
BackSpace "${terminfo[kbs]}"
Home "${terminfo[khome]}"
End "${terminfo[kend]}"
Insert "${terminfo[kich1]}"
Delete "${terminfo[kdch1]}"
Up "${terminfo[kcuu1]}"
Down "${terminfo[kcud1]}"
Left "${terminfo[kcub1]}"
Right "${terminfo[kcuf1]}"
PageUp "${terminfo[kpp]}"
PageDown "${terminfo[knp]}"
)

function bind2maps () {
local i sequence widget
local -a maps

while [[ "$1" != "--" ]]; do
maps+=( "$1" )
shift
done
shift

sequence="${key[$1]}"
widget="$2"

[[ -z "$sequence" ]] && return 1

for i in "${maps[@]}"; do
bindkey -M "$i" "$sequence" "$widget"
done
}

bind2maps emacs -- BackSpace backward-delete-char
bind2maps viins -- BackSpace vi-backward-delete-char
bind2maps vicmd -- BackSpace vi-backward-char
bind2maps emacs -- Home beginning-of-line
bind2maps viins vicmd -- Home vi-beginning-of-line
bind2maps emacs -- End end-of-line
bind2maps viins vicmd -- End vi-end-of-line
bind2maps emacs viins -- Insert overwrite-mode
bind2maps vicmd -- Insert vi-insert
bind2maps emacs -- Delete delete-char
bind2maps viins vicmd -- Delete vi-delete-char
bind2maps emacs viins vicmd -- Up up-line-or-history
bind2maps emacs viins vicmd -- Down down-line-or-history
bind2maps emacs -- Left backward-char
bind2maps viins vicmd -- Left vi-backward-char
bind2maps emacs -- Right forward-char
bind2maps viins vicmd -- Right vi-forward-char

# Make sure the terminal is in application mode, when zle is
# active. Only then are the values from $terminfo valid.
if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
function zle-line-init () {
emulate -L zsh
printf '%s' ${terminfo[smkx]}
}
function zle-line-finish () {
emulate -L zsh
printf '%s' ${terminfo[rmkx]}
}
zle -N zle-line-init
zle -N zle-line-finish
else
for i in {s,r}mkx; do
(( ${+terminfo[$i]} )) || debian_missing_features+=($i)
done
unset i
fi

unfunction bind2maps

fi # [[ -z "$DEBIAN_PREVENT_KEYBOARD_CHANGES" ]] && [[ "$TERM" != 'emacs' ]]

zstyle ':completion:*:sudo:*' command-path /usr/local/sbin \
/usr/local/bin \
/usr/sbin \
/usr/bin \
/sbin \
/bin \
/usr/X11R6/bin

(( ${+aliases[run-help]} )) && unalias run-help
autoload -Uz run-help

if [[ -z "$skip_global_compinit" ]]; then
autoload -U compinit
compinit
fi
export PATH=$PATH:/opt/terraform

我在这个唯一的系统上使用 debian jessie,其他的 wheezy 和 Ubuntu 工作。

最佳答案

显然,如果您想在那里使用 Prezto,您需要将 Prezto 安装到 root 用户的主目录。 root shell 不会从 SUDO_USER 的主页加载 runco​​ms。 – 4ae1e1

关于linux - ZSH 不使用 "sudo -s"加载我的 prezto 配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34185009/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com