I would like to execute the shell command "cmatrix" whenever I open a terminal. How to go about achieving this?
3 Answers
You can add cmatrix
command in your ~/.bashrc
file located at home folder:
echo 'cmatrix' >> ~/.bashrc
NOTE: Please ensure that you use >>
, the append operator. If you use >
, it will replace your whole ~/.bashrc
with cmatrix
only.
-
3Please make very sure that you use
>>
(two arrows!) and not only>
. Otherwise this will replace your file and delete the old one. You could also open the file with any text editor and manually append the line.– Byte Commander ♦Sep 29, 2015 at 11:14 -
3@snoop i would safely use $gedit ~/.bashrc. Thanks for the caution :) Sep 29, 2015 at 11:32
-
4Of course this is a good answer, but just to be exact, this way the command will be executed each time a
bash
instance is spawned by the user, so not only ingnome-terminal
.– kosSep 29, 2015 at 11:33 -
Because you tagged your question with gnome-terminal
, you can also use a a custom command for your gnome-terminal
profile.
The advantage, the command is executed only for a specific profile and not always when the bash is started somewhere.
But first install dconf-editor
. If you make a mistake in the steps below, you will need this tool
sudo apt-get install dconf-editor
Now open gnome-terminal
and edit your profile settings and use this command
sh -c "cmatrix;bash"
as you can see in the screenshot below. If you don't use the bash, replace bash
with your shell.
If you made a mistake and gnome-terminal
is unusable, use use dconf-editor
to correct your problem:
Start dconf-editor
and navigate to the settings of GNOME terminal and change the values for custom-command
and use-custom-command
in the settings for your gnome-terminal
profile
-
1If the user makes a mistake, they may not be able to pull up a terminal in the first place.– KevinSep 29, 2015 at 13:59
-
-
-
-
I'm using Fedora with XFCE desktop. I encountered problems when Fedora boots, by using the solution provided by @snoop, and the solution provided by @AB gave me the "Failed to execute child process (no such file or directory)" error. Searching for a solution, finally I used a script saved as ~/bin/cmatrix_launcher.sh
with this content:
#!/bin/bash
cmatrix -baC cyan
/bin/bash
throwing then it as a custom command in the xfce4-terminal
settings (screenshot attached)
-
1