Gis*_*nas 5 gnu-screen cd-command
我想做一些类似于这里写的 东西而不使用 zsh(我使用 bash),但是如果我尝试用
screen 'cd /home/cataldo/Programs'
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Cannot exec 'cd home/cataldo/Programs': No such file or directory
Run Code Online (Sandbox Code Playgroud)
exec 之后没有 qoutes 它也不起作用。双引号没有区别。使用 bash -c "cd .." 不起作用。
可能是某些权限问题或屏幕在启动时以特殊用户身份执行命令?
非常感谢您的帮助!
screen --version
Screen version 4.00.03jw4 (FAU) 2-May-06
cat /etc/debian_version
6.0.3
Run Code Online (Sandbox Code Playgroud)
Wie*_*and 10
它不起作用,因为它cd是一个 shell 内置命令 (try which cd)。Screen 有一个chdir 命令,您可以使用它来实现您的目标:将以下内容放入您的 .screenrc 中:
chdir /home/cataldo/Programs
Run Code Online (Sandbox Code Playgroud)
现在开始屏幕,你应该在指定的目录中。
screen不知道,cd因为它是一个内置的 shell,所以screen不能执行它。但是,screen有一个内置命令chdir. 如果您从命令行chdir自行执行,会话screen中的所有新窗口screen都将在您的 $HOME 中启动。如果执行chdir /home/cataldo/Programs从screen命令行,在所有新的窗口screen会话将开始/home/cataldo/Programs。
如果您想在启动新screen会话时在不同目录中打开 3 个窗口,请在您~/.screenrc定义目录中chdir,然后立即启动一个新窗口。
# Start these windows when screen starts up
chdir /home/cataldo/Programs
screen 0
chdir /usr/local/bin
screen 1
chdir /tmp
screen 2
chdir
Run Code Online (Sandbox Code Playgroud)
From man 1 screen(注意最后一行)
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.
Hardcopy and log files are always written to the window's default
directory, not the current directory of the process running in the window.
You can use this command multiple times in your .screenrc to start
various windows in different default directories, but the last chdir value
will affect all the windows you create interactively.
Run Code Online (Sandbox Code Playgroud)