Module: Chitin::Builtins::Prompts

Included in:
Chitin::Builtins
Defined in:
lib/chitin/commands/builtins.rb

Instance Method Summary collapse

Instance Method Details

#last_elapsedObject

Get the elapsed time of the last command.



125
126
127
# File 'lib/chitin/commands/builtins.rb', line 125

def last_elapsed
  SESSION.last_elapsed || 0.0
end

#last_elapsed_formattedObject



129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/chitin/commands/builtins.rb', line 129

def last_elapsed_formatted
  hours = (last_elapsed / 3600).floor
  min   = ((last_elapsed - 3600 * hours) / 60).floor
  sec   = last_elapsed - 3600 * hours - 60 * min

  if hours > 0
    "%02d:%02d:%f" % [hours, min, sec]
  elsif min > 0
    "%02d:%f" % [min, sec]
  else
    "%f" % sec
  end
end

#minimalist_promptObject

Minimalist.



155
156
157
# File 'lib/chitin/commands/builtins.rb', line 155

def minimalist_prompt
  '.'.red + '.'.yellow + '.'.cyan + ' '
end

#promptObject

The standard prompt. Must return a string. Override this to provide a custom prompt.



120
121
122
# File 'lib/chitin/commands/builtins.rb', line 120

def prompt
  "#{ENV['USER']}: #{short_pwd} % "
end

#time_elapsed_working_multiline_promptObject

My personal fancy shell. On the first line it has the time, elapsed time of the last run command, and the shortened working directory. On the second line, it has three colored dots.



147
148
149
150
151
152
# File 'lib/chitin/commands/builtins.rb', line 147

def time_elapsed_working_multiline_prompt
  "(".purple + Time.now.to_s + ") ".purple +
    "(".purple + "last => " + "#{last_elapsed_formatted}".cyan + ") ".purple +
    "(".purple + short_pwd.yellow + ")\n".purple +
    '.'.red + '.'.yellow + '.'.cyan + ' '
end