How can I run a command on xterm startup i.e. when an xterm terminal is launched a the command is already executed?
I have edited the .bashrc file to add this line:
xterm "ls"
But this does not work.
Please suggest what should I do to acheive this.
Thanks.
I use this:
http://linux.die.net/man/1/rxvt
According to the
bash
manual,~/.bashrc
is used for interactive shells. xterm runs a shell, so perhaps your "does not work" causes a chain of xterm's.The xterm program sets these environment variables which are useful for scripting:
XTERM_VERSION
andXTERM_SHELL
. In your~/.bashrc
file, you could use the former to run thexterm -ls
once only:which seems to be what you are asking for:
ls
is done.A more useful-seeming way of showing an
ls
on shell startup would be to runls
in each shell as it is started (for that case, you do not need run a separatexterm
). Again, you can use environment variables to do this once (in case you runbash
to make a subshell):