Bash 'cd' с cdable_vars: как подавить эхо CWD?

Вот кое-что, что будет работать либо в zsh , либо в bash , чтобы добиться того, что вам нужно.

Если вы выполните очистку gem clean , чтобы удалить старую версию tmuxinator , она исправит ситуацию при следующем запуске кода (т.е. при следующем запуске оболочки, если в ваш .zshrc )

# Allow shell-specific code
function sh_is_zsh { [[ -n $ZSH_VERSION ]]; }
function sh_is_bash { [[ -n $BASH_VERSION ]]; }

# Update "tmuxinator.{z,ba}sh" if needed
tmuxinator_source="$XDG_CONFIG_HOME/tmuxinator/tmuxinator.$(sh_is_zsh && echo zsh || echo bash)"
# If not a regular file or symlink to one
if [[ ! -f $tmuxinator_source ]]; then
    # If doesn't exist or is a symlink to nowhere
    if [[ ! -e $tmuxinator_source ]] || [[ -L $tmuxinator_source ]] && [[ ! -e $tmuxinator_source ]]; then
        echo "Creating ${tmuxinator_source##*/} symlink:"
        tmp=$(gem which tmuxinator) # tmuxinator executable
        tmp=$(readlink -f "${tmp%/*}/../completion") # completion scripts dir
        ln -fsv "$tmp/${tmuxinator_source##*/}" "$tmuxinator_source"
        unset tmp
    else
      echo "Not creating symlink at at existing:"
      ls -lF "$tmuxinator_source"
    fi
fi

source "$tmuxinator_source"
unset $tmuxinator_source

Обратите внимание, что это шелл-чек , очищающий от дополнительных точек домового.

3
24.02.2017, 18:56
1 ответ

Я разобрался с этим с помощью следующего уродливого хака:

$ type -a cd
cd is aliased to `cd $1 >/dev/null'
cd is a shell builtin

Другими словами, добавьте эту строку в свой ~ / .bashrc :

alias cd='cd >/dev/null' 
2
27.01.2020, 21:25

Теги

Похожие вопросы