Open mate-terminal and do command

mate-terminal --window opens a new terminal. Which is nice.
But I want to execute a command after doing this. Like git status -u

I’ve seen the -e/--command argument in the help but it does not seem to do anything

mate-terminal --window --working-directory="~/site/example.com" --command="git status -u"

How can I do this?

Hi @janw.oostendorp, I’m pretty sure your command is fine but the command exits so fast you cannot see it. Run a command that sticks around, like top to see what I mean.

But mate-terminal has a profile setting and I recall, in the past, I made a separate profile just to include this because it’s not always desired. Edit -> Profile Preferences does change your default profile, something to keep in mind.

Under Title and Command is When command exits and can be set to Hold the terminal open.

There are other solutions but this should do the trick.

2 Likes

Hi @janw.oostendorp,

what about if you just open a terminal with Ctrl + Alt + t and then run any commands you want?. :smiley:

So alternatively, if you don’t mind something a little bit dirty:

Wrap what you want to do in a file, and add a bash invocation after that:

wrapper.sh:

#! /bin/bash

ls # Or you know, your command...

bash

Then use:

mate-terminal -e /path/to/your/wrapper.sh

There a two variants for this . (As I know)

  1. Make the terminal not exit with command finnish (Has to be in profile settings)
  2. Wrap the command in shell script and make it wait for input after the command is finnished.

2.1 something like this

#!/bin/bash

git status -u
read -p "Are you ready to exit? " yn

case $yn in
    * ) exit ;;
esac

Another way is without the terminal (zenity required)
The script would look like this

[code]#!/bin/sh

cd ~/site/example.com

git_status(){
#Commands go here
echo “–> git status -u”
echo “”
git status -u
echo “–> Done”
}

git_status 2>&1
| zenity --text-info --title=“Git status” --width=500 --height=500[/code]
Make it executable and when you call the script use the next line (change the path and the script name).

sh -c "/path/to/script_name.sh"

That would be good with caja actions , don’t ya’ think.

Да Ивчо, I think something like this in /home/user/.config/caja/scripts would do

[code]#!/bin/sh

git_status(){
#Commands go here
echo “–> git status -u”
echo “”
git status -u
echo “–> Done”
echo “”
}
for arg
do
if [ -d “$arg” ]; then
echo “Folder: ${arg}”
git_status 2>&1
else
echo “You must select a folder”
fi
done | zenity --text-info --title=“Git status” --width=500 --height=500[/code]

What are these Caja actions you mention?
It sounds useful for other things I might want to do.

Ahh now I understand it. the --command just does that command then sends an exit. So I’ll add an extra profile and switch to that when doing this.

I’m currently doing this manual. But on some projects I open 3 terminal-tabs(directories), and I want to do different checks on each tab.

1 Like

Caja actions is a tool that adds custom commands to the right click menu . Like the ones extract here and etc. It uses scripts or external commands for the actions . With this you can even replacate the right click menus of windows “Move to , copy to” actions . Simular thing to putting the script of @anon94368460 in scrypts folder but caja actions is more powerfull .