Hacker News new | past | comments | ask | show | jobs | submit login

You want $CDPATH for that in Bash.



CDPATH is not a very good bookmarking system, as you can't bookmark several directories that have the same name, and you are forced to bookmark all the siblings of the item you wish to bookmark, which can be a problem with flat hierarchies. So if bookmarking directories is the goal, CDPATH might not be the best way. And one off bookmarking functions are easy to write.

Admittedly for the description given, it does sound like CDPATH would work. But I'm going to assume there's a reason, and functions that change the current working directory are the perfect example of functions that can not be run in a subshell, so will have to be rewritten to fish, which is what the author was providing.


I simplified the example, cdc does more than just a change the directory. `cdc -t name` changes to the directory and attaches to the tmux session of the same name if it exists, and if it doesn't, sets up my tmux layout for development.


whilst reading your above comment i wondered why you chose not to use environment variables instead. e.g.:

  $ export cdc_stuff='/Users/me/src/project_stuff'
  $ cd $cdc_stuff
however, now it's clear.

in the event you're looking for alternatives, perhaps porting your code to (e.g.) ruby could work.

just in case, here's the isbn number of a book called, 'Build Awesome Command-Line Applications in Ruby 2,' from the pragmatic bookshelf: 978-1-93778-575-8


Ok. I didn't know about cdc.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: