Reputation: 301
Simple question :
I am using cmder and i would like to be able to define ~
(or ~USERID
) as my %USERPROFILE%
environment variables. I edited %CMDERROOT%\config\aliases
to add this line : ~=%USERPROFILE%
it does work for ls
command but not for cd
for instance.
Is there a better way to have this unix-like user profile aliases ?
Upvotes: 3
Views: 5974
Reputation: 11
I don´t remember where I got it but add these lines to your profile:
function cuserprofile { Set-Location ~ }
Set-Alias ~ cuserprofile -Option AllScope
you just hit ~ (enter) and you'll send to your home directory.
PS. I'm using PowerShell in cmder, regards.
Upvotes: 1
Reputation: 301
For those who would like an answer to that question, it have been addressed in the following github issue :
https://github.com/cmderdev/cmder/issues/41
Not a direct answer, but a decent work-around was mentioned in the discussion on that page:
clink, the vendor package that would handle this has a similar issue report marked as "wontfix" So, here's the workaround
I'm using an AutoHotKey script for that:
#IfWinActive ahk_class VirtualConsoleClass
::~::D:/nicolas
#IfWinActive
It replaces automatically ~ with D:/nicolas in ConEmu console (and only ConEmu console)
I have not tried it in a script executed from the command line, but it works from the command line directly, as nicolas suggests.
Upvotes: 2