我正在努力让我的config.fish开始工作,但是它没有像预期的那样工作,我真的不明白为什么。我所能做的就是猜测Fish可能无法处理if语句中的if语句?这是我的密码:
echo "so far so good"
if status --is-interactive
# Chips: fish plugin manager
if [ -e ~/.config/chips/build.fish ] ; . ~/.config/chips/build.fish ; end
echo "def interactive"
# Don't use vi keybindings in unknown terminals,
# since weird things can happen.
set acceptable_terms xterm-256color screen-256color xterm-termite
echo "acceptable terms: $acceptable_terms"
echo "term: $TERM"
if contains $TERM acceptable_terms
echo "good to go!"
fish_vi_key_bindings
# Load pywal colors
cat ~/.cache/wal/sequences
else
echo "why?!?!?"
end
end我得到的是:
so far so good
def interactive
acceptable terms: xterm-256color screen-256color xterm-termite
term: xterm-termite
why?!?!?但我希望看到的是:
so far so good
def interactive
acceptable terms: xterm-256color screen-256color xterm-termite
term: xterm-termite
good to go!但是,当我在shell中运行这个程序时,如果工作正常的话:
❯ echo "term: $TERM / acceptable: $acceptable_terms"
term: xterm-termite / acceptable: xterm-256color screen-256color xterm-termite
❯ if contains $TERM $acceptable_terms
echo "yay!"
end
yay!这里会发生什么事?
发布于 2018-08-24 15:44:50
当然,fish可以处理嵌套的if语句!
if contains $TERM acceptable\_terms
缺少第二个变量上的$!
if contains $TERM $acceptable_termshttps://stackoverflow.com/questions/52007598
复制相似问题