6

I would like to execute the shell command "cmatrix" whenever I open a terminal. How to go about achieving this?

12

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.

  • 3
    Please 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 '15 at 11:14
  • 2
    @snoop i would safely use $gedit ~/.bashrc. Thanks for the caution :) – baalkikhaal Sep 29 '15 at 11:32
  • 4
    Of 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 in gnome-terminal. – kos Sep 29 '15 at 11:33
  • Or you can edit the .bashrc file with gedit ~/.bashrc & – Chef Pharaoh Sep 30 '15 at 5:59
6

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.

enter image description here


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

  • 1
    If the user makes a mistake, they may not be able to pull up a terminal in the first place. – Kevin Sep 29 '15 at 13:59
  • @Kevin therefore the last part in my answer. – A.B. Sep 29 '15 at 14:05
  • Where are they supposed to type sudo apt-get install dconf-editor? – Kevin Sep 29 '15 at 14:05
  • @kevin good point, thank you. I have changed my answer. – A.B. Sep 29 '15 at 14:16
  • @kevin But there is always tty1 and so on. ;) – A.B. Sep 29 '15 at 14:19
-1

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)

xfce4-terminal with custom command

  • 1
    [ "xfce4-terminal" ] is always true. – muru Sep 13 '17 at 9:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.