Class: Rprompt::GitTrack
- Inherits:
-
PromptItem
- Object
- PromptItem
- Rprompt::GitTrack
- Defined in:
- lib/rprompt.rb
Instance Attribute Summary
Attributes inherited from PromptItem
Instance Method Summary collapse
-
#count ⇒ Integer
Number of commits ahead or behind remote.
-
#initialize(config, state) ⇒ GitTrack
constructor
A new instance of GitTrack.
-
#show ⇒ String
Terminal representation of the tracking.
Methods inherited from PromptItem
Methods included from Deco
Constructor Details
#initialize(config, state) ⇒ GitTrack
Returns a new instance of GitTrack.
67 68 69 70 |
# File 'lib/rprompt.rb', line 67 def initialize(config, state) @state = state super(config) end |
Instance Method Details
#count ⇒ Integer
Note:
works only if remote branch is tracked
Returns number of commits ahead or behind remote.
74 75 76 77 |
# File 'lib/rprompt.rb', line 74 def count commandResult.match(/#{@state}\s+([0-9]+)/) $1.to_i end |
#show ⇒ String
Returns terminal representation of the tracking.
80 81 82 |
# File 'lib/rprompt.rb', line 80 def show count != 0 ? termShow({:color => color, :symbol => symbol, :content => count}) : '' end |