Joined September 2011
·

Martin Svalin

Developer at Mynewsdesk
·
Stockholm, Sweden
·
·
·

Posted to Inheriting from: Struct over 1 year ago

It's useful to know that you can customize a Struct with a block as well. This code has the same effect as your example where you inherit from Struct, and it doesn't create an extra, unnamed class to inherit from.

Car = Struct.new(:brand, :model) do
  def car_brand_and_model
    "My car is a: #{brand} #{model}
  end
end

Just thought I'd point it out for completeness…

If you want to show the currently running command when you're not at the prompt, you can set the iterm title in a DEBUG trap.

All in all, my solution is:

function iterm_title { echo -ne "\033]0;$@\007"; }
trap 'iterm_title $BASH_COMMAND' DEBUG
export PROMPT_COMMAND='iterm_title ${PWD##*/}$(__git_ps1 :%s)'
Achievements
187 Karma
8,248 Total ProTip Views