Gnome-Terminal New Tab with Alias as Command to Execute

Executing alias commands in newly opened Tabs

You could try switching from an alias to a function in your .bashrc. According to bash's documentation, functions are better than aliases for most situations. In your situation, since you're not running bash as a login environment, it might work better. Add this to your .bashrc and comment out the alias:

router4() {
/usr/bin/ssh root@172.16.17.4
}

If that doesn't work on its own, you could try adding export -f router4 in your .bashrc after defining router4.

I want to write a bashrc alias that launches commands in multiple new terminals

You can try:

gnome-terminal --tab -e "psql mydb" --tab -e "Jupyter lab" --tab -e "metabase"

How to open a new tab in GNOME Terminal from command line?

#!/bin/sh

WID=$(xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)"| awk '{print $5}')
xdotool windowfocus $WID
xdotool key ctrl+shift+t
wmctrl -i -a $WID

This will auto determine the corresponding terminal and opens the tab accordingly.

open gnome terminal tabs programmatically and execute commands in sequence

Ok, I think i get it. As i mentioned in the comments the first thing that comes to mind for reaching your school desktop from the outside is to ssh into the school gate and from there ssh into your desktop with something like:

$ ssh -t gate.school.edu ssh desktop_name

There's only one tab then, so your problem doesn't exist.

However there's something very cool with your current setup:

From home it's almost as if you had a direct connection to your desktop machine, so you can scp into it directly and forget about gate. With the solution above that's not possible anymore because we end up with an indirect connection: If you want to scp you have to do it from gate and that sucks.

Check out this article on using ssh's ProxyCommand feature:

  • Transparent Multi-hop SSH

You get the best of both worlds then :)

Run script in new tab in gnome terminal

The reason that:

gnome-terminal --tab -- '/bin/bash -c "ls";bash'

Fails is that it is looking for a program with that as its name. This is an instance of chain loading where the rest of the arguments are passed as is to exec. Those first argument is the name of the program. With this quoting it receives the entire command and options as a single program name.

Change the quoting to:

gnome-terminal --tab -- /bin/bash -c "ls;bash"

Open gnome terminal new tab in current folder with git prompt command

function set_git_prompt() {
__git_ps1 "\u@\h:\w" "\\\$ "
[ $VTE_VERSION ] && __vte_prompt_command
}

if [ -f /etc/bash_completion.d/git-prompt ]
then
GIT_PS1_SHOWCOLORHINTS='yes'
GIT_PS1_SHOWDIRTYSTAT='yes'
GIT_PS1_SHOWSTASHSTATE='yes'
GIT_PS1_SHOWUNTRACKEDFILES='yes'
GIT_PS1_SHOWUPSTREAM='auto

PROMPT_COMMAND='set_git_prompt'
fi


Related Topics



Leave a reply



Submit