相关疑难解决方法(0)

[ -t 1 ] 检查什么?

zsh当我bash在 Windows 上启动时,我刚刚找到了一种启动方式

https://www.howtogeek.com/258518/how-to-use-zsh-or-another-shell-in-windows-10/

建议在.bashrc.

# Launch Zsh
if [ -t 1 ]; then
exec zsh
fi
Run Code Online (Sandbox Code Playgroud)

什么[ -t 1 ]意思?

这是真的吗?

那么,我可以这样做吗?

exec zsh
Run Code Online (Sandbox Code Playgroud)

shell bash zsh test

15
推荐指数
3
解决办法
6718
查看次数

为什么 zsh 在 OS X 上错误地列出了我的提示?

我想弄清楚为什么 zsh 的提示看起来像这样:

zsh 提示示例

(以文本形式):

\[\]\u\[\] at \[\]\h\[\] in \[\]\w\[\]$(__git_ps1) \[\]$(git_diff)\n\[\]($(date +'1:MikesMBP.local ')) \[\]$\[\]
Run Code Online (Sandbox Code Playgroud)

我希望它在调用 zsh 之前像在 bash 中一样正常列出我的密码和用户名。这是我的 .zshrc:

# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
setopt appendhistory autocd beep extendedglob nomatch notify
bindkey -v
# End of lines configured by zsh-newuser-install
# The following lines were added by compinstall
zstyle :compinstall filename '/Users/mike/.zshrc'

autoload -Uz compinit
compinit
# End of lines added by compinstall
Run Code Online (Sandbox Code Playgroud)

这只是第一次启动 zsh 时创建的标准配置。我已经尝试了内置的 OS X zsh 和自制软件的 zsh,它们产生了相同的错误。你看到会导致这种情况的东西吗?

osx shell prompt zsh

0
推荐指数
1
解决办法
306
查看次数

为什么从源代码编译时 Bash 的行为有所不同?

我跑了

git clone https://git.savannah.gnu.org/git/bash.git
cd bash/
./configure
make
./bash
Run Code Online (Sandbox Code Playgroud)

我注意到新启动的 Bash 实例没有从父 shell 继承环境,特别是定义 shell 提示符的 PS1 变量。继承适用于/bin/bash

源文件列表/bin/bash与和相同./bash

./bash  -lixc exit 2>&1 | sed -n 's/^+* \(source\|\.\) //p'
/bin/bash  -lixc exit 2>&1 | sed -n 's/^+* \(source\|\.\) //p'
Run Code Online (Sandbox Code Playgroud)

编辑:正如aviro提到的,PS1是在没有导出的情况下定义的,所以当我尝试导出它时它被继承了,所以我最初的问题是错误的。在我的机器上 PS1 在两个文件中定义 /etc/bash/bashrc

# If not running interactively, don't do anything
[[ $- != *i* ]] && return
[[ $DISPLAY ]] && shopt -s checkwinsize
PS1='[\u@\h \W]\$ '
Run Code Online (Sandbox Code Playgroud)

/etc/bash/bashrc.d/artix.bashrc

if ${use_color} ; then
    if [[ …
Run Code Online (Sandbox Code Playgroud)

bash source-code

0
推荐指数
1
解决办法
159
查看次数

标签 统计

bash ×2

shell ×2

zsh ×2

osx ×1

prompt ×1

source-code ×1

test ×1