如何使GNU屏幕不在OS X的主目录中启动?


11

screen与Linux(至少Ubuntu,Red Hat和Gentoo)和OS X 10.4(老虎)相比,GNU Screen()在OS X 10.5(Leopard)和10.6(Snow Leopard)上的行为有所不同。在10.5和10.6中,新屏幕(用screen或制成^A c)总是将我放在主目录中~。在Linux和OS X Tiger中,新屏幕具有pwd最初创建屏幕的位置。

编造了一些例子来说明我的意思:

虎:

$ cd ~/foo
$ pwd
/Users/ben/foo
$ screen
$ pwd
/Users/ben/foo
$ screen # or ^A c
$ pwd
/Users/ben/foo

豹,雪豹:

$ cd ~/foo
$ pwd
/Users/ben/foo
$ screen
$ pwd
/Users/ben
$ screen # or ^A c
$ pwd
/Users/ben

如何使豹和雪豹的行为像老虎过去?

Answers:


7

一种更好的检查运行类型的screen方法是运行command -V screen。这将告诉您它是运行二进制文件(在这种情况下,将给出完整路径)还是shell别名,函数等。

要检查的另一件事chdir是您的命令~/.screenrc或系统范围的命令screenrc


3
终于发现正在做什么。我有shell -$SHELL一节是从同事那里抄过来的。除去问题后,问题就消失了。它不行为相同的方式在Linux上,等
本杰明·奥克斯

3

screen(1)手册页介绍的屏幕chdir命令

   chdir [directory]

   Change the current directory of screen to the specified directory or,
   if called without an argument, to your home  directory  (the  value  of  the
   environment  variable  $HOME).  All windows that are created by means of the
   "screen" command from within ".screenrc" or by means of "C-a : screen
   ..." or "C-a c" use this as their default directory.  Without a chdir command,
   this would be the directory from which screen was  invoked. …

编程会话的“我的屏幕”配置包括以下命令

chdir "$HOME/Projects"

2

第一步是确保屏幕不是别名。

输入alias并查找screen。请注意,此列表可能很长。您可能需要键入alias | grep screen以将小麦与谷壳分开。

如果screen结果是类似的别名,则cd ~ && screen可以使用删除该别名unalias screen


更好:使用type screen
thiagowfx

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.