Home

Awesome

pathos.rb - CLI for editing a PATH env variable

Background

If you're like me, you might have a number of export PATH statements littering your shell resource file (e.g., .zshrc, .bashrc, etc). Over time, many directory entries get added and revised. Those that remain eventually become unnecessary, are mistakenly duplicated, or represent directories that no longer exist on the system. This is my attempt at cleaning up PATH environment variable. Hopefully, others will find this to be useful.

Demo

pathos.rb DEMO

Built with the following:

Installation

  1. Clone repo
  2. Change to repo directory (Assuming repo was downloaded to ~/Downloads/pathos.rb on MacOS)
cd ~/Downloads/pathos.rb
  1. Run it
ruby pathos.rb

IMPORTANT

Each time you save your changes to the directory list, pathos.rb will build a revised export $PATH statement that is written to $HOME/.pathos.env.

To use the new PATH, $HOME/.pathos.env MUST BE SOURCED to take effect within your shell.

source $HOME/.pathos.env

Navigation / Commands

KeyDescription
↑/kup
↓/jdown
oadd path (below current selected path) [1]
Oadd path (above current selected path) [1]
xremove current path
Xremove non-existent paths
Dremove duplicate paths
Ssave
qquit

Color Highlighting

ColorDescription
<span style="background-color:black">   <span style="color:yellow">Yellow</span>   </span>Shows current selected path</span>
<span style="background-color:black">   <span style="color:red">Red</span>   </span>Indicates paths that do not exist
<span style="background-color:black">   <span style="color:aqua">Aqua</span>   </span>Indicates duplicate paths