Run a Script Each Time Terminal Window Opened
So I have written a simple bash script to run a program called "cmatrix" everytime a new terminal window is opened.
I have changed the permissions on the file so it is r-x for everyone, and verified that it will run exactly how I want it to when called, but now I don't know where to put the script so that it runs on each new bash terminal launch. I know that if I want it to run on startup I would place it in usr/local/bin, but I only want it to run when I open a new terminal window.
Very very simple:
cmatrix -bs -C cyan
Any and all help is appreciated!
Thanks
linux bash terminal linux-mint bash-scripting
add a comment |
So I have written a simple bash script to run a program called "cmatrix" everytime a new terminal window is opened.
I have changed the permissions on the file so it is r-x for everyone, and verified that it will run exactly how I want it to when called, but now I don't know where to put the script so that it runs on each new bash terminal launch. I know that if I want it to run on startup I would place it in usr/local/bin, but I only want it to run when I open a new terminal window.
Very very simple:
cmatrix -bs -C cyan
Any and all help is appreciated!
Thanks
linux bash terminal linux-mint bash-scripting
What do you mean by "terminal window"? A window from a (specific?) terminal emulator? Any tty? Any interactive Bash session? Please edit the question and clarify. (Side note: I think/usr/local/bin
has nothing to do with running anything on startup. Not really relevant to your question though, even if I'm right).
– Kamil Maciorowski
Jan 23 at 9:27
add a comment |
So I have written a simple bash script to run a program called "cmatrix" everytime a new terminal window is opened.
I have changed the permissions on the file so it is r-x for everyone, and verified that it will run exactly how I want it to when called, but now I don't know where to put the script so that it runs on each new bash terminal launch. I know that if I want it to run on startup I would place it in usr/local/bin, but I only want it to run when I open a new terminal window.
Very very simple:
cmatrix -bs -C cyan
Any and all help is appreciated!
Thanks
linux bash terminal linux-mint bash-scripting
So I have written a simple bash script to run a program called "cmatrix" everytime a new terminal window is opened.
I have changed the permissions on the file so it is r-x for everyone, and verified that it will run exactly how I want it to when called, but now I don't know where to put the script so that it runs on each new bash terminal launch. I know that if I want it to run on startup I would place it in usr/local/bin, but I only want it to run when I open a new terminal window.
Very very simple:
cmatrix -bs -C cyan
Any and all help is appreciated!
Thanks
linux bash terminal linux-mint bash-scripting
linux bash terminal linux-mint bash-scripting
asked Jan 23 at 9:01
LiefLief
1
1
What do you mean by "terminal window"? A window from a (specific?) terminal emulator? Any tty? Any interactive Bash session? Please edit the question and clarify. (Side note: I think/usr/local/bin
has nothing to do with running anything on startup. Not really relevant to your question though, even if I'm right).
– Kamil Maciorowski
Jan 23 at 9:27
add a comment |
What do you mean by "terminal window"? A window from a (specific?) terminal emulator? Any tty? Any interactive Bash session? Please edit the question and clarify. (Side note: I think/usr/local/bin
has nothing to do with running anything on startup. Not really relevant to your question though, even if I'm right).
– Kamil Maciorowski
Jan 23 at 9:27
What do you mean by "terminal window"? A window from a (specific?) terminal emulator? Any tty? Any interactive Bash session? Please edit the question and clarify. (Side note: I think
/usr/local/bin
has nothing to do with running anything on startup. Not really relevant to your question though, even if I'm right).– Kamil Maciorowski
Jan 23 at 9:27
What do you mean by "terminal window"? A window from a (specific?) terminal emulator? Any tty? Any interactive Bash session? Please edit the question and clarify. (Side note: I think
/usr/local/bin
has nothing to do with running anything on startup. Not really relevant to your question though, even if I'm right).– Kamil Maciorowski
Jan 23 at 9:27
add a comment |
1 Answer
1
active
oldest
votes
Assuming bash is your default shell, any bash command you put into your ~/.bashrc
file will be executed when opening a new terminal window (interactive shell). For example, putting echo "Hello"
at the end of your ~/.bashrc
file will popup this message)
For your script to be executed on opening a new bash window, you can just:
- Move your script to
/usr/local/bin/
- Call your script from your
~/.bashrc
file
Notice:
You don't absolutely need to move your script to
/usr/local/bin/
, but it's convenient as it doesn't require the extra step to modify your path, or to call your script with its absolute path.
To actually call your script from your
~/.bashrc
, just add your script name at the end of the file:
my_cool_script.sh
If your script is a single line long, you can actually put that line in your
~/.bashrc
instead of your script name, in your case:
cmatrix -bs -C cyan
@KamilMaciorowski Thanks for the polished details. Answer edited.
– Yoric
Jan 23 at 10:55
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1397349%2frun-a-script-each-time-terminal-window-opened%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Assuming bash is your default shell, any bash command you put into your ~/.bashrc
file will be executed when opening a new terminal window (interactive shell). For example, putting echo "Hello"
at the end of your ~/.bashrc
file will popup this message)
For your script to be executed on opening a new bash window, you can just:
- Move your script to
/usr/local/bin/
- Call your script from your
~/.bashrc
file
Notice:
You don't absolutely need to move your script to
/usr/local/bin/
, but it's convenient as it doesn't require the extra step to modify your path, or to call your script with its absolute path.
To actually call your script from your
~/.bashrc
, just add your script name at the end of the file:
my_cool_script.sh
If your script is a single line long, you can actually put that line in your
~/.bashrc
instead of your script name, in your case:
cmatrix -bs -C cyan
@KamilMaciorowski Thanks for the polished details. Answer edited.
– Yoric
Jan 23 at 10:55
add a comment |
Assuming bash is your default shell, any bash command you put into your ~/.bashrc
file will be executed when opening a new terminal window (interactive shell). For example, putting echo "Hello"
at the end of your ~/.bashrc
file will popup this message)
For your script to be executed on opening a new bash window, you can just:
- Move your script to
/usr/local/bin/
- Call your script from your
~/.bashrc
file
Notice:
You don't absolutely need to move your script to
/usr/local/bin/
, but it's convenient as it doesn't require the extra step to modify your path, or to call your script with its absolute path.
To actually call your script from your
~/.bashrc
, just add your script name at the end of the file:
my_cool_script.sh
If your script is a single line long, you can actually put that line in your
~/.bashrc
instead of your script name, in your case:
cmatrix -bs -C cyan
@KamilMaciorowski Thanks for the polished details. Answer edited.
– Yoric
Jan 23 at 10:55
add a comment |
Assuming bash is your default shell, any bash command you put into your ~/.bashrc
file will be executed when opening a new terminal window (interactive shell). For example, putting echo "Hello"
at the end of your ~/.bashrc
file will popup this message)
For your script to be executed on opening a new bash window, you can just:
- Move your script to
/usr/local/bin/
- Call your script from your
~/.bashrc
file
Notice:
You don't absolutely need to move your script to
/usr/local/bin/
, but it's convenient as it doesn't require the extra step to modify your path, or to call your script with its absolute path.
To actually call your script from your
~/.bashrc
, just add your script name at the end of the file:
my_cool_script.sh
If your script is a single line long, you can actually put that line in your
~/.bashrc
instead of your script name, in your case:
cmatrix -bs -C cyan
Assuming bash is your default shell, any bash command you put into your ~/.bashrc
file will be executed when opening a new terminal window (interactive shell). For example, putting echo "Hello"
at the end of your ~/.bashrc
file will popup this message)
For your script to be executed on opening a new bash window, you can just:
- Move your script to
/usr/local/bin/
- Call your script from your
~/.bashrc
file
Notice:
You don't absolutely need to move your script to
/usr/local/bin/
, but it's convenient as it doesn't require the extra step to modify your path, or to call your script with its absolute path.
To actually call your script from your
~/.bashrc
, just add your script name at the end of the file:
my_cool_script.sh
If your script is a single line long, you can actually put that line in your
~/.bashrc
instead of your script name, in your case:
cmatrix -bs -C cyan
edited Jan 23 at 10:54
answered Jan 23 at 9:32
YoricYoric
3196
3196
@KamilMaciorowski Thanks for the polished details. Answer edited.
– Yoric
Jan 23 at 10:55
add a comment |
@KamilMaciorowski Thanks for the polished details. Answer edited.
– Yoric
Jan 23 at 10:55
@KamilMaciorowski Thanks for the polished details. Answer edited.
– Yoric
Jan 23 at 10:55
@KamilMaciorowski Thanks for the polished details. Answer edited.
– Yoric
Jan 23 at 10:55
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1397349%2frun-a-script-each-time-terminal-window-opened%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What do you mean by "terminal window"? A window from a (specific?) terminal emulator? Any tty? Any interactive Bash session? Please edit the question and clarify. (Side note: I think
/usr/local/bin
has nothing to do with running anything on startup. Not really relevant to your question though, even if I'm right).– Kamil Maciorowski
Jan 23 at 9:27