Gnome终端和Zsh:将当前目录保留在新标签页/窗口中


12

我在带有Zsh的Arch上运行gnome 3.10.1。我面临的问题是,当我从终端窗口创建新的选项卡或窗口时,它将当前目录重置为我的主目录。

我已经尝试过:gnome-terminal:在new选项卡中跟踪目录,但是没有用。

我坚信也许这可能是.zshrc文件上的某些配置,因此,我将其清理干净并仅添加以下行:

. /etc/profile.d/vte.sh

但是,它没有按预期工作。

是的,此文件存在,其内容如下:

# Copyright © 2006 Shaun McCance <shaunm@gnome.org>
# Copyright © 2013 Peter De Wachter <pdewacht@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

# Not bash or zsh?
[ -n "$BASH_VERSION" -o -n "$ZSH_VERSION" ] || return 0

# Not an interactive shell?
[[ $- == *i* ]] || return 0

# Not running under vte?
[ "${VTE_VERSION:-0}" -ge 3405 ] || return 0

__vte_urlencode() (
  # This is important to make sure string manipulation is handled
  # byte-by-byte.
  LC_ALL=C
  str="$1"
  while [ -n "$str" ]; do
    safe="${str%%[!a-zA-Z0-9/:_\.\-\!\'\(\)~]*}"
    printf "%s" "$safe"
    str="${str#"$safe"}"
    if [ -n "$str" ]; then
      printf "%%%02X" "'$str"
      str="${str#?}"
    fi
  done
)

# Print a warning so that anyone who's added this manually to his PS1 can adapt.
# The function will be removed in a later version.
__vte_ps1() {
  echo -n "(__vte_ps1 is obsolete)"
}

__vte_osc7 () {
  printf "\033]7;file://%s%s\a" "${HOSTNAME:-}" "$(__vte_urlencode "${PWD}")"
}

__vte_prompt_command() {
  printf "\033]0;%s@%s:%s\007%s" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}" "$(__vte_osc7)"
}

case "$TERM" in
  xterm*|vte*)
    [ -n "$BASH_VERSION" ] && PROMPT_COMMAND="__vte_prompt_command" 
    [ -n "$ZSH_VERSION"  ] && chpwd_functions+=(__vte_osc7)
    ;;
esac

true

这真是困扰我...

有什么解决办法吗?


2
它与gnome-terminal有关,与zsh不相关。尽管链接背后的错误是ubuntu-gnome的错误,但这似乎是一个已报告的错误。
Risto Salminen

1
你有尝试过terminator吗?
RSFalcon7 2013年

是的,终结器工作正常,但是,例如,nautilus-open-terminal扩展名总是打开gnome-terminal,我无法更改它……
Henrique Barcelos

1
只是想指出,在我的rc文件中找到vte.sh之后,我不得不重新启动gnome-terminal。只是通过保存它并打开一个新的选项卡/窗口并不能工作..(使用bash / arch / gnome3.10)
The Silent Boatman

Answers:


16

我不知道您是否仍然遇到此问题,但是我发现我的问题是我在终端配置文件中将/ bin / zsh作为自定义命令运行。禁用该功能可以解决此问题-仍然将zsh用作我的主要shell。

终端配置文件


使用Fedora为我完全解决了问题,非常感谢!
Sven Hager

1
进行更改将意味着使用默认的bash而不是zsh。那么如何解决这个问题呢?
阿尔菲,

@Alfie用户未使用其默认外壳程序(可能是bash)。这意味着所执行的用于设置提示的命令(在登录时设置/etc/profile.d/vte.sh)不是正确的命令,并且终端不知道Shell的当前目录。
xhienne

屏幕截图不再是最新的。第二个选项不再存在。勾选第一个就可以了。这是默认设置,但是我想必须将ZSH设置为默认外壳chsh
slhck

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.