sindresorhus / project-ideas

Need a JavaScript module or looking for ideas? Welcome ✨
543 stars 9 forks source link

Shortcut CLI Navigator #55

Open webcaetano opened 8 years ago

webcaetano commented 8 years ago

I was wondering about a simple cli tool, that create folder shortcuts. To help developers switch from project folders. It should be very simple, with a few commands like: add list remove

Ideal example:

cd flying-pigs-project
go --add "fpp"
go fpp // cd ~/Users/webcaetano/rainbow/flying-pigs-project

I'm not sure if already exist an tool like that , i did a good research and didn't find anything. If someone knows something, please reply it.

Something similar to this https://github.com/Angelmmiguel/pm But write in node.

Qix- commented 8 years ago

Node isnt going to be able to do this all that well. cd is a builtin, meaning it belongs to whatever shell program you're using (e.g. Bash, Zsh, CMD).

Processes work in environments, which are basically isolated sandboxes of configuration that are inherited down from the parent process' environment. This means when you run node, you're using what are essentially copies of the parent processes environment variables (including CD or CWD, the current directory).

Unless your shell has a specific interface for it, you can't modify the parent processes' environment. The only way to do this is to source the child process, which runs the process in the current environment thus allowing modifications. To my knowledge, not only does sourcing not exist on Windows, but as well you can only source shell scripts (don't quote me on that).

That means the majority of your commands are going to amount to shell scripts or aliases that source child shell scripts. Not sure how much Node is really going to benefit you in that case.

webcaetano commented 8 years ago

Thanks for the clearly answer @Qix-

Qix- commented 8 years ago

No problem. Good idea, though! :+1:

webcaetano commented 8 years ago

@Qix- i was thinking , node can write a .bat or a .sh based on the OS, and include it to global PATH.

Qix- commented 8 years ago

It can. it all depends on how much you want Node to do.

webcaetano commented 8 years ago

@Qix- currently i do all this by editing by hand a .bat file... And all i find in the web is in a shell script like pm.

I'll start to create this module, and post the link of the repo here in a short.

al-the-x commented 8 years ago

Dunno if it helps, but I use pushd and popd for this in bash / zsh... That appears to work in shelljs

Is there a specific environment you're looking for?

forivall commented 8 years ago

@webcaetano There's lots of scripts that do this: bashmarks, zshmarks, https://github.com/rupa/z

As for windows ¯(ツ)/¯ there's probably some powershell thing that does this better than bat's

dawsbot commented 8 years ago

Awesome idea, but I think the functionality is already covered well enough with fasd. It's a fuzzy file finder cd.

So when I want to switch to a project called object-types I can type z object-types and I've been cd'd there from anywhere in my file system.

wayneashleyberry commented 8 years ago

I have a zsh function called c which is just a fancy cd set to my PROJECTS directory. Whenever c is called it sets the alias gg to go back to the project directory.

screen shot 2016-04-29 at 3 46 30 pm screen shot 2016-04-29 at 3 46 46 pm

Source is here: https://github.com/wayneashleyberry/zshrc/blob/master/.zsh/functions/c

jayrdeaton commented 6 years ago

I wrote a command line utility to do this, specifically for MacOS using osascript commands. It’s on npm, called deplace.

wayneashleyberry commented 6 years ago

I'd also recommend https://github.com/rupa/z which learns which directories you use the most and lets you jump to them without manually specifying a path or shortcut.