Developers have their own tools to work. May not be the coolest but best suit their workflow. Let’s write a Terminator (v. 0.97) plugin and source those shortcuts into any environment.
The Terminator Plugin
Paste file below in ~/.config/terminator/plugins/source_helpers.py.
#!/usr/bin/python"""source_helpers.py - Terminator Plugin to source shared cli shortcuts"""importosimportgtkimportterminatorlib.pluginaspluginfromterminatorlib.translationimport_fromterminatorlib.utilimportwidget_pixbuf# Every plugin you want Terminator to load *must* be listed in 'AVAILABLE'AVAILABLE=['SourceHelper']classSourceHelper(plugin.MenuItem):"""Add custom commands to the terminal menu"""capabilities=['terminal_menu']dialog_action=gtk.FILE_CHOOSER_ACTION_SAVEdialog_buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_SAVE,gtk.RESPONSE_OK)def__init__(self):plugin.MenuItem.__init__(self)defcallback(self,menuitems,menu,terminal):"""Add our menu items to the menu"""item=gtk.MenuItem(_('Terminal SourceHelper'))item.connect("activate",self.terminal_source_helpers,terminal)menuitems.append(item)defterminal_source_helpers(self,_widget,terminal):"""Handle the source_helpers of terminal"""f=open(os.getenv("HOME")+'/loki/env/bash_aliases_shared','r')output=''forlineinf:line=line.strip()iflen(line)>0andline[0]!="#":output=output+line+" ; "output=base64.b64encode(output.encode('zlib'))output="echo "+output+" | base64 --decode | python -c 'import zlib,sys;sys.stdout.write(zlib.decompress(sys.stdin.read()))' > /tmp/source; source /tmp/source; rm /tmp/source; clear"terminal.vte.feed_child(" "+output+"\n")
Terminator is not a must, a key binding for tmux will do if you get the idea.
Aliases and Functions
Extract aliases and functions that should be shared into a separated file, e.g. ~/.bash_aliases_shared.
123456789
# aliases / functions defined here will be usable in both local and remote machine# do not store cmd started with whitespace into historyHISTCONTROL=ignoreboth
# better output jsonalias json='python -mjson.tool'# you can add your own stuffs here, even auto-completion setup
Add line below in your ~/.bash_aliases, so they can be used in local as well.
1
source ~/.bash_aliases_shared
Bonus
Terminator usually come in handy when reading local settings on remote environment. One use case is to reset the terminal size. You should encountered that ssh session won’t resize when the terminal window is resized. New area cannot be filled. Simply craft another Terminator plugin to solve this problem. It is much like the previous plugin but we resize the session with stty instead.
123456
# ... plugin instantiation and menu registration ...defterminal_resize(self,_widget,terminal):cols=terminal.vte.get_column_count()rows=terminal.vte.get_row_count()terminal.vte.feed_child("stty cols "+str(cols)+"; stty rows "+str(rows)+"\n")