On 6 Nov 2008, at 20:09, Francis Fish wrote:
> Sorry to revive this old thread but I just came up with this, to > tell you what directory your irb or console session is running in. > > Already saved my bacon a couple of times on projects that post > through to each other. > > http://www.pastie.org/308981 Hi Francis I think this is the longest running thread on NWRUG :) I had a go at making this dynamic and working a bit more like my zsh prompt[1], but it doesn't handle multi-line strings properly. It's a fudge, I just wrote the methods that stop irb aborting... class Pwd def initialize(format) @format = format end def to_s @format.gsub("PWD", Dir.pwd.split("/")[-3..-1].join("/")) end def to_str to_s end def gsub!(*args) @format.gsub!(*args) end def %(*args) to_s.send(:%, *args) end end IRB.conf[:PROMPT][:MY_PROMPT] = { :PROMPT_I => Pwd.new("PWD> "), :PROMPT_S => Pwd.new("PWD%l "), :PROMPT_C => Pwd.new("PWD>> "), :RETURN => "%s\n" } IRB.conf[:PROMPT_MODE] = :MY_PROMPT Ashley [1] http://aviewfromafar.net/2007/10/21/moving-to-zsh -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "NWRUG" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/nwrug-members?hl=en -~----------~----~----~----~------~----~------~--~---
