OT: Set Windows cmd path to just current directoy

I'm doing some programming where I run some commands inside a project direc tory. It would be nice if I could change the command prompt from

C:\Users\Wanderer\swdev\Workspace\myProject>

to just

myProject>

so that I have more room in the console window to see commands and output y et still have the feedback that I am working on the right project. I know ' prompt $p$g' is the same 'prompt %CD%$g'. Is there a %Something% that retur ns the current directory? Is there a way to define an environment variable that returns the current directory?

Thanks

Reply to
Wanderer
Loading thread data ...

for /D %n in (.) do set currdir=%~nn

sets the variable currdir as specified.

In a batch files, use double percent symbols.

--
RoRo
Reply to
Robert Roland

If you really feel the need to burrow five directories deep, you can create an alias for that path. In the old days you'd use the subst command to do that, but now all the trendy kids are using mklink. Google those and/or run them with /? for more.

I also live at the commmand prompt, but I don't feel a need to maintain the fiction that my Windows box is a multiuser system. So I just use directory names like c:\dev\whatever.

-- john, KE5FX

Reply to
John Miles, KE5FX

While this works, it doesn't really work for me. I would have to run that code every time I change directories.

Reply to
Wanderer

mklink works great. You don't know how many superuser and stackoverflows I read and nobody mentions this. Thank you.

Reply to
Wanderer

On Sun, 15 Nov 2015 13:26:42 -0800 (PST), Wanderer Gave us:

You can also use the NET command..

Net use and net share in particular, can be used to assign a name to a path. Alias no longer exists.

Type net /? to see the commands listing

Type net use /? You can assign a share name to a drive and path.

and net share /?

You can assign a share name to a path then use the share name at the prompt to access the path. You can make them persistent as well, and this method can be used to make a universal development path to a location and have it shared across a network segment or user group.

Here is a good help

formatting link

Reply to
DecadentLinuxUserNumeroUno

On Sun, 15 Nov 2015 13:26:42 -0800 (PST), Wanderer Gave us:

net use z: \\computer\folder

Map the Z: drive to the network path //computer/folder.

Reply to
DecadentLinuxUserNumeroUno

NET USE is good, as dlu1 said, but you probably Want something lighter-weight.

Fortunately NTFS supports symlinks. I forget the syntax, but if you search for "ntfs symlink" it'll tell you.

Cheers

Phil Hobbs

Reply to
Phil Hobbs

On Mon, 16 Nov 2015 04:32:30 -0800 (PST), Phil Hobbs Gave us:

"dlu1"?

Delusional little upstart? :-)

Reply to
DecadentLinuxUserNumeroUno

You said it, I didn't. ;)

Cheers

Phil Hobbs

Reply to
Phil Hobbs

On Mon, 16 Nov 2015 05:09:22 -0800 (PST), Phil Hobbs Gave us:

Well, I haven't done 'ludes' in decades, so de-lude-sional fits.

Ooops... I said that too. :-)

Reply to
DecadentLinuxUserNumeroUno

My sympathies. All to often I wind up working with WinXX command line prompts that wind up wrapping or coming close to it. ( The problem also exists under Linux, but I have a bit more control over the directory structure there. )

The... er, "command prompt prompt" is set either via the 'prompt' command or from the environment variable PROMPT.

Since there isn't -- as far as I know -- any handy '$x' value that says "just show the last part of $p please", you _could_ use the /K option and a script to set the PROMPT variable. Once.

cmd.exe /k myscript.cmd

will start the command processor, execute 'myscript.cmd', and then remain open. The problem is that when you change directories, the prompt doesn't change, which is probably worse that what you already have.

More details can be found here:

Unfortunately, the WinXX command shells don't appear have the same flexibility for the PROMPT setting as (e.g.) Linux offers. For the 'bash' command shell, for example, you can embed command strings inside the 'PS1' environment variable such as this one:

PS1="\u@\h [\$(ls | wc -l)]:\$ "

The syntax is ugly, no question about it, but it tells 'bash' to invoke the 'ls' and 'wc' commands to count the number of files in the current directory each time the prompt displays.

More details here for the curious:

About the only suggestion I can offer as far as your current environment is to suggest that you consider installing a replacement shell, though I don't specifically know one which would offer what you're looking for. Here are some you could start your investigation with:

Sorry I couldn't be more help.

Frank McKenney McKenney Associates

--
  So far as a thing is universal it is full of cosmic things.  And so 
  far as a thing is universal it is full of comic things. 
                      -- G.K. Chesterton / Spiritualism (1908)
Reply to
Frnak McKenney

On Mon, 16 Nov 2015 04:32:30 -0800 (PST), Phil Hobbs Gave us:

Net use will allow one to reduce any path to a single drive letter string..

So will file explorer and the gui share mechanisms, btw.

Once assigned, it can be accessed from within the CLI VDM.

So the entire console width would be available for him to see the return output of his commands, which is what he was looking for.

Reply to
DecadentLinuxUserNumeroUno

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.