terminator icon indicating copy to clipboard operation
terminator copied to clipboard

Feature: Insert terminal name to terminal (for broadcast)

Open jacceko opened this issue 2 years ago • 4 comments

Problem: I want to ssh to 30 servers with different names at the same time, (password is the same) - I don't want on start ssh on start Terminator but during work - on choosen servers not all servers in a group.

My solution is easy: If I put my saved layout - my servers names and user in "Terminal name" field",
then only one think which I need is to insert "terminal name" to all terminal in group - similar to "Insert Terminal Number".

What will be to do: add option "Insert Terminal Name to Terminal" for shortcuts and terminal context menu.

If if will have for ex. 30 terminals in grid - all with Terminal Name: [email protected], [email protected] .... (If I want not to log to some of it, I disable broadcast for it)

I will can now: "ssh ("Insert Terminal Name ") - enter (and now I am ssh to 30 servers at the same time).

Jacceko

jacceko avatar Nov 19 '21 18:11 jacceko

Should be fairly easy to write as a plugin, and I may take a stab at it.

mattrose avatar Nov 19 '21 21:11 mattrose

It will be excellent!

jacceko avatar Nov 20 '21 08:11 jacceko

insert terminal number got the index will change when modify panel layout. // for example: close or move some panel.

so insert terminal name may be one possible solution

yurenchen000 avatar Apr 09 '22 22:04 yurenchen000

I make a simple patch to add insert terminal name support: https://github.com/yurenchen000/terminator/commits/add_insert_term_name // based on v2.1.1


diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py
index 4715e86c..26bc7b2c 100644
--- a/terminatorlib/terminal.py
+++ b/terminatorlib/terminal.py
@@ -567,6 +567,10 @@ class Terminal(Gtk.VBox):
 
         menu.append(Gtk.SeparatorMenuItem())
 
+        item = Gtk.MenuItem.new_with_mnemonic(_('_Insert terminal name'))
+        item.connect('activate', lambda x: self.emit('enumerate', 2))
+        menu.append(item)
+
         item = Gtk.MenuItem.new_with_mnemonic(_('_Insert terminal number'))
         item.connect('activate', lambda x: self.emit('enumerate', False))
         menu.append(item)
diff --git a/terminatorlib/terminator.py b/terminatorlib/terminator.py
index 6cbf4d68..2af294b9 100644
--- a/terminatorlib/terminator.py
+++ b/terminatorlib/terminator.py
@@ -588,8 +588,13 @@ class Terminator(Borg):
             terminals.extend(win_terminals)
 
         for term in self.get_target_terms(widget):
-            idx = terminals.index(term)
-            term.feed(numstr % (idx + 1))
+            # print('term:', term.get_window_title())
+            if pad == 2:
+                name = term.get_window_title()
+                term.feed(name.encode())
+            else:
+                idx = terminals.index(term)
+                term.feed(numstr.encode() % (idx + 1))
 
     def get_sibling_terms(self, widget):
         termset = []


if you wish term custom title override term title:

-name = term.get_window_title()
+name = term.titlebar.get_custom_string() or term.get_window_title()



here is demo record:

https://user-images.githubusercontent.com/8458213/162595132-e4147bd2-b0e3-4d55-a30c-789ad57871cd.mp4

yurenchen000 avatar Apr 09 '22 23:04 yurenchen000

these days I feel that broardcast insert terminal name is more often used than terminal number

especially the terminal number is unstable, it may changed when change split layout:

  • add/remove/arrange split in current/other window/tab

that made terminal number very unpredictable. In comparison, terminal name can be set inside terminal by program (console_sequence) or override in terminator by user, that's very Interactive and Operability.

Considering that split screen and broadcast input are such a feature for terminator And inserting the terminal name is so basic.

think about add this feature to terminator rather than plugin ?

yurenchen000 avatar Nov 02 '22 00:11 yurenchen000

@mattrose @Vulcalien

will you think about make this as built-in ?

seems it's not possible to change the group menu by a normal plugin, the default plugin type can't handle this, maybe some dirty hack can do it.

//seems plugin.MenuItem only for context-menu, and this group feature put into context-menu seems counterintuitive

a PR for built-in: https://github.com/gnome-terminator/terminator/compare/master...yurenchen000:terminator:add_insert_term_name-2

yurenchen000 avatar Nov 19 '22 22:11 yurenchen000

Sorry @yurenchen000, I rewrote this as a plugin. You have a good point that it was a really useful function, but I didn't like two things:

  1. It's a really niche feature. I can't imagine 95% of our users ever using this feature, and to have it permanently and irrevocably litter the very limited space on the context menu was too much.
  2. The code was unmaintainable. Over-riding the do_enumerate method with a magic number that tells terminator to feed text to a window was... Well, I could tell it was going to be a maintenance challenge in the long run.

The resulting code is not that much more verbose, it has to be explicitly enabled, and it's much more clear what the code is doing.

mattrose avatar Nov 20 '22 04:11 mattrose

@mattrose Got it, The point 2 can be improved, but The point 1 is really about the design concept

// I use terminal name occasionally for cluster operate. On the contrary, I rarely use insert numbers.

Thanks for making plugins for our minority users 😂


BTW, is there any way to sort & splitter the context-menu items ? I installed several plugins, Previously, the order could be adjusted by modifying the script file name and item name. Seems this way not work anymore recently.

// That's one reason I don't often use the context-menu.

yurenchen000 avatar Nov 20 '22 05:11 yurenchen000

@mattrose Would you consider extending the plugin system's capabilities for group-menu

Maybe it should be discussed in a new post But problem in this post is an entry point

yurenchen000 avatar Nov 20 '22 14:11 yurenchen000

Lemme mock it up in the titlebar group menu. I think we can fit it in there.

mattrose avatar Nov 20 '22 17:11 mattrose

Sorry, I misread your code, and I thought you wanted to add it to the context menu. I thought about this last night and don't actually have a problem with adding it to the group menu.

I'm going to pull in the group menu stuff. I'll keep the plugin in mainly for my own purposes.

mattrose avatar Nov 20 '22 18:11 mattrose

@mattrose Would you consider extending the plugin system's capabilities for group-menu

Maybe it should be discussed in a new post But problem in this post is an entry point

@mattrose

(ง •̀_•́)ง yes, (maybe you also missed the mp4 demo which also in group-menu too 🙈) I guess we are on the same page now.

Thank you for spending time with minority users, me.



And, BTW think about extend the plugin system capacity for group-menu ? so that we can really Leave these features to the plugin. (to be honest, I want create a plugin for another group feature, I have to do hack things for now

If you agree with this, I'll open a new post for plugin system feature request.

yurenchen000 avatar Nov 21 '22 02:11 yurenchen000