Skip to content

tje/path-compactor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Path Compactor

Simple tool for squishing long file system paths into shorter abbreviations. Kind of nice for shell prompts, not so much for anything else.

Iterates over path fragments between directory separators and squashes them based on length and case formatting. Home directory prefixes are replaced with with a ~ character.

Full Compact
/path/to/long-directory-name /path/to/ldn
/Users/someone/projects/masterpiece ~/pro/mas
/camelCaseFragment /cCF
/snake_case_v2 /scv2

Invoking the executable will compact the first provided argument or else the current working directory.

Shell prompt

cargo build the thing and move the binary somewhere easy to remember.

Example with bash, assuming the binary is located at ~/bin/pc:

# ~/.bashrc
PS1="\$(dirname \$(~/bin/pc))/\$(basename \$PWD) $ "

Or PowerShell:

function Prompt {
  $P = (~/bin/pc.exe)
  Write-Host "$(Split-Path $P)\" -ForegroundColor darkgray -NoNewline
  Write-Host (Split-Path $PWD -Leaf) -NoNewline
  Write-Host " PS>" -ForegroundColor cyan -NoNewline
  return " "
}

About

Tool for abbreviating file paths

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages