class EnhancedPrompt::Prompt::Token::Dir

Public Instance Methods

dir_abbreviated1(limit=50) click to toggle source

TODO cd /home/sato/work/serverspec_test/spec/nyaa corrupt this if limit =40

# File lib/enhanced_prompt/token/dir.rb, line 37
def dir_abbreviated1(limit=50)
  dir = _base
  if _dir_full.length >= limit then
    _dir.split_paths.reverse.each do |path|
      if dir.length + path.length <= limit
        dir = path + dir
      else
        return Pathname.new('...')+dir
      end
    end
    _dir_full
  else
    _dir_full
  end
end
dir_full() click to toggle source
# File lib/enhanced_prompt/token/dir.rb, line 30
def dir_full
  _dir_full
end

Private Instance Methods

_base() click to toggle source
# File lib/enhanced_prompt/token/dir.rb, line 58
def _base
  @_base ||= _dir_full.basename
end
_dir() click to toggle source
# File lib/enhanced_prompt/token/dir.rb, line 54
def _dir
  @_dir ||= _dir_full.split.first
end
_dir_full() click to toggle source
# File lib/enhanced_prompt/token/dir.rb, line 62
def _dir_full
  @_dir_full ||= Pathname.new(::Dir.pwd)
end