Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Insert terminal name to terminal (for broadcast) #540

Closed
jacceko opened this issue Nov 19, 2021 · 12 comments
Closed

Feature: Insert terminal name to terminal (for broadcast) #540

jacceko opened this issue Nov 19, 2021 · 12 comments
Labels
enhancement New feature or request

Comments

@jacceko
Copy link

jacceko commented Nov 19, 2021

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: user1@server1.com, user2@server2.com ....
(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

@mattrose mattrose added the enhancement New feature or request label Nov 19, 2021
@mattrose
Copy link
Member

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

@jacceko
Copy link
Author

jacceko commented Nov 20, 2021

It will be excellent!

@yurenchen000
Copy link

yurenchen000 commented Apr 9, 2022

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
Copy link

yurenchen000 commented Apr 9, 2022

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:

terminator_insert_term_name.mp4

@yurenchen000
Copy link

yurenchen000 commented Nov 2, 2022

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
Copy link

yurenchen000 commented Nov 19, 2022

@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:
master...yurenchen000:terminator:add_insert_term_name-2

mattrose added a commit to mattrose/terminator that referenced this issue Nov 20, 2022
This plugin inserts the name of the terminal, as determined by
Terminal.get_window_title() to all open terminals. Fixes gnome-terminator#540
@mattrose
Copy link
Member

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.

@yurenchen000
Copy link

yurenchen000 commented Nov 20, 2022

@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
Copy link

yurenchen000 commented Nov 20, 2022

@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
Copy link
Member

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

@mattrose
Copy link
Member

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.

@yurenchen000
Copy link

yurenchen000 commented Nov 21, 2022

@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.

mattrose added a commit to mattrose/terminator that referenced this issue Aug 26, 2023
This plugin inserts the name of the terminal, as determined by
Terminal.get_window_title() to all open terminals. Fixes gnome-terminator#540
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants