Open webcaetano opened 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.
Thanks for the clearly answer @Qix-
No problem. Good idea, though! :+1:
@Qix- i was thinking , node can write a .bat or a .sh based on the OS, and include it to global PATH.
It can. it all depends on how much you want Node to do.
@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.
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?
@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
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.
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.
Source is here: https://github.com/wayneashleyberry/zshrc/blob/master/.zsh/functions/c
I wrote a command line utility to do this, specifically for MacOS using osascript commands. It’s on npm, called deplace.
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.
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:
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.