How to set gnome-terminal tab title. Permanently…

I’ve been looking for this a few times without success. There are some nasty proposals with setting PS1 variable or other tricks with .bashrc mods. Weak and doesn’t actually work.I needed a way to make a bash script that opens several tabs with fixed t…

I’ve been looking for this a few times without success. There are some nasty proposals with setting PS1 variable or other tricks with .bashrc mods. Weak and doesn’t actually work.
I needed a way to make a bash script that opens several tabs with fixed titles and with fixed start directories and with already started programs (for example tail/less of log files). Or solutions are very complicated.

There’s a simple way.

There’s a nice option for gnome-terminal -t “Tab title” which allows you to set a title for a tab. But in default profile (a switchable terminal behavior configuration) any program or bash prompt can change tab’s title. So actually setting tab title doesn’t work permanently.

A good solution is to create a new profile (let’s call it “NoTitleChange”) with options set to not to allow tab change. To do this, in gnome-terminal go to Edit->profiles… click New, apply new name. Then in tab Title and Command from drop box (When commands set own title…) choose Keep initial title.


Now you can invoke

gnome-terminal –tab-with-profile=NoTitileChange -t “My Permanent title”

and nothing will change the tab’s title.
You can play with these and other options to create many tabs in one window.
gnome-terminal –tab-with-profile=NoTitleChange -t “PERMANENT” –tab-with-profile=NoTitleChange -t “TABS ARE”  –tab-with-profile=NoTitleChange -t “AWESOME”
I’m using these other options

-e, –command=STRING
                 Execute the argument to this option inside the terminal.

–working-directory=DIRNAME
                 Set the terminal’s working directory to DIRNAME.

–geometry=GEOMETRY
                 X geometry specification (see “X” man page), can be specified once per window to be opened.

For example

gnome-terminal –tab-with-profile=NoTitleChange -t “src” –working-directory=/opt/workspace/play/mnp/repo/console_gxt2/mnpc  –tab-with-profile=NoTitleChange -t “DevMode” –working-directory=/opt/workspace/play/mnp/repo/console_gxt2/mnpc –command=”mvn initialize exec:exec -Pdevel”

Now you can create start script that opens proper working dirs (with source code for example) and with server logs open. And you’re ready to go!
You May Also Like

Inconsistent Dependency Injection to domains with Grails

I've encountered strange behavior with a domain class in my project: services that should be injected were null. I've became suspicious as why is that? Services are injected properly in other domain classes so why this one is different?

Constructors experiment

I've created an experiment. I've created empty LibraryService that should be injected and Book domain class like this:

class Book {
def libraryService

String author
String title
int pageCount

Book() {
println("Finished constructor Book()")
}

Book(String author) {
this()
this.@author = author
println("Finished constructor Book(String author)")
}

Book(String author, String title) {
super()
this.@author = author
this.@title = title
println("Finished constructor Book(String author, String title)")
}

Book(String author, String title, int pageCount) {
this.@author = author
this.@title = title
this.@pageCount = pageCount
println("Finished constructor Book(String author, String title, int pageCount)")
}

void logInjectedService() {
println(" Service libraryService is injected? -> $libraryService")
}
}
class LibraryService {
def serviceMethod() {
}
}

Book has 4 explicit constructors. I want to check which constructor is injecting dependecies. This is my method that constructs Book objects and I called it in controller:

class BookController {
def index() {
constructAndExamineBooks()
}

static constructAndExamineBooks() {
println("Started constructAndExamineBooks")
Book book1 = new Book().logInjectedService()
Book book2 = new Book("foo").logInjectedService()
Book book3 = new Book("foo", 'bar').logInjectedService()
Book book4 = new Book("foo", 'bar', 100).logInjectedService()
Book book5 = new Book(author: "foo", title: 'bar')
println("Finished constructor Book(Map params)")
book5.logInjectedService()
}
}

Analysis

Output looks like this:

Started constructAndExamineBooks
Finished constructor Book()
Service libraryService is injected? -> eu.spoonman.refaktor.LibraryService@2affcce2
Finished constructor Book()
Finished constructor Book(String author)
Service libraryService is injected? -> eu.spoonman.refaktor.LibraryService@2affcce2
Finished constructor Book(String author, String title)
Service libraryService is injected? -> null
Finished constructor Book(String author, String title, int pageCount)
Service libraryService is injected? -> null
Finished constructor Book()
Finished constructor Book(Map params)
Service libraryService is injected? -> eu.spoonman.refaktor.LibraryService@2affcce2

What do we see?

  1. Empty constructor injects dependencies.
  2. Constructor that invokes empty constructor explicitly injects dependencies.
  3. Constructor that invokes parent's constructor explicitly does not inject dependencies.
  4. Constructor without any explicit call declared does not call empty constructor thus it does not inject dependencies.
  5. Constructor provied by Grails with a map as a parameter invokes empty constructor and injects dependencies.

Conclusion

Always explicitily invoke empty constructor in your Grail domain classes to ensure Dependency Injection! I didn't know until today either!

Spring security authentication-success-handler-ref and authentication-failure-handler-ref does not work with KerberosServiceAuthenticationProvider

I'm using SpringSecurity with KerberosServiceAuthenticationProvider which is Kerberos security extension. You can read how to use it on extension author's blog.But you cannot use handler on form-login to catch authorization result. It's because of inne...I'm using SpringSecurity with KerberosServiceAuthenticationProvider which is Kerberos security extension. You can read how to use it on extension author's blog.But you cannot use handler on form-login to catch authorization result. It's because of inne...