How many times have you done "ls; cd <xx>; cd ..; ls; cd <yy>; etc"? With that tedium in mind, I set out to create a simple ncurses utility to combine ls and cd. As luck would have it, actually implementing the directory changing functionality was done last. I guess I have to chalk this one up to experience.
You could make it work, if you think about the problem a bit differently. Have your program output a command, like "cd /your/dir", when it exits. Then run it with eval from the shell (assuming a bash shell.)
eval $(yourprogram)
... now, set up an alias:
alias something='eval $(yourprogram)'
and there you go. "something" can now change your directory (and do anything else by echoing a command.)
2 comments
[ 4.2 ms ] story [ 22.0 ms ] threadeval $(yourprogram)
... now, set up an alias: alias something='eval $(yourprogram)'
and there you go. "something" can now change your directory (and do anything else by echoing a command.)