Skip to content

Instantly share code, notes, and snippets.

@dphase
Created July 12, 2018 14:41
Show Gist options
  • Save dphase/80d3d795321cf229ed1737bcc0e12c94 to your computer and use it in GitHub Desktop.
Save dphase/80d3d795321cf229ed1737bcc0e12c94 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
# ------------------------------------------------------------------------
dir = ENV['PWD'].gsub(ENV['HOME'], '~').split('/')
pwd = dir.each.with_index.inject('') do |d,(el,i)|
c = (i == (dir.count - 1)) ? el : el[0]
d << c.to_s + '/'
end.byteslice(0..-2)
print pwd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment