如何在 xterm 启动时使用 运行 命令?
How to run a command on the startup of an xterm?
如何在 xterm 启动时 运行 命令,即当 xterm 终端启动时命令已经执行?
我已编辑 .bashrc 文件以添加此行:
xterm "ls"
但这不起作用。
请建议我应该怎么做才能实现这一目标。
谢谢。
我用这个:
-e /bin/bash -login
-e command [arguments]
Run the command with its command-line arguments in the rxvt window;
also sets the window title and icon name to be the basename of the
program being executed if neither -title (-T) nor -n are given on the
command line. If this option is used, it must be the last on the
command-line. If there is no -e option then the default is to run the
program specified by the SHELL environment variable or, failing that,
sh(1).
根据 bash
手册,~/.bashrc
用于交互式 shell。 xterm 运行 是一个 shell,所以也许你的 "does not work" 导致了一系列 xterm。
xterm 程序设置了这些对脚本有用的 environment variables:XTERM_VERSION
和 XTERM_SHELL
。在您的 ~/.bashrc
文件中,您可以使用前者来 运行 一次 xterm -ls
:
if [[ -z "$XTERM_VERSION" ]]
then
xterm -hold -e ls &
fi
这似乎是你要的:
- 它将 运行 一个 xterm 如果不是 运行 来自现有的 xterm
- 它防止 xterm 在
ls
完成后关闭。
在 shell 启动时显示 ls
的更有用的方法是在每个 shell 启动时显示 运行 ls
(对于这种情况,您不需要 运行 单独的 xterm
)。同样,您可以使用环境变量来执行此操作 once(以防您 运行 bash
制作一个 subshell):
if [[ -z "$XTERM_ONCE" ]]
then
export XTERM_ONCE=$(date)
ls
fi
如何在 xterm 启动时 运行 命令,即当 xterm 终端启动时命令已经执行?
我已编辑 .bashrc 文件以添加此行:
xterm "ls"
但这不起作用。
请建议我应该怎么做才能实现这一目标。
谢谢。
我用这个:
-e /bin/bash -login
-e command [arguments]
Run the command with its command-line arguments in the rxvt window; also sets the window title and icon name to be the basename of the program being executed if neither -title (-T) nor -n are given on the command line. If this option is used, it must be the last on the command-line. If there is no -e option then the default is to run the program specified by the SHELL environment variable or, failing that, sh(1).
根据 bash
手册,~/.bashrc
用于交互式 shell。 xterm 运行 是一个 shell,所以也许你的 "does not work" 导致了一系列 xterm。
xterm 程序设置了这些对脚本有用的 environment variables:XTERM_VERSION
和 XTERM_SHELL
。在您的 ~/.bashrc
文件中,您可以使用前者来 运行 一次 xterm -ls
:
if [[ -z "$XTERM_VERSION" ]]
then
xterm -hold -e ls &
fi
这似乎是你要的:
- 它将 运行 一个 xterm 如果不是 运行 来自现有的 xterm
- 它防止 xterm 在
ls
完成后关闭。
在 shell 启动时显示 ls
的更有用的方法是在每个 shell 启动时显示 运行 ls
(对于这种情况,您不需要 运行 单独的 xterm
)。同样,您可以使用环境变量来执行此操作 once(以防您 运行 bash
制作一个 subshell):
if [[ -z "$XTERM_ONCE" ]]
then
export XTERM_ONCE=$(date)
ls
fi