lhmouse / nano-win

GNU nano text editor for Windows [WARNING: The master branch is constantly rebased and force-pushed so don't expect it to be steady!! -end WARNING]
https://files.lhmouse.com/nano-win/
GNU General Public License v3.0
210 stars 25 forks source link

Enhancement: Use same profile location for Admin as for user #36

Closed eabase closed 2 years ago

eabase commented 2 years ago

99% of all PC users are only using 1 account (not counting sudo, or Administrator) accounts, while often mixing privilege escalated shells. Therefore it make no sense to have nano blindly (without telling user) that it is trying to load the .nanorc from a completely different location.

Enhancements    
    + .nanorc is loaded from "%USERPROFILE%\.nanorc" with normal privilege
      and from "%ALLUSERSPROFILE%\.nanorc" with elevated privilege.
    + Systemwide nanorc is loaded from "%ALLUSERSPROFILE%\nanorc".

ALLUSERSPROFILE   C:\ProgramData
USERPROFILE       C:\Users\<username>
eabase commented 2 years ago

Same should be said for the filepos_history as reported in #37 .

lhmouse commented 2 years ago

Loading distinct profiles is conventional for nano, as it allows different color schemes of titlebar, statusbar, etc. If you start nano via sudo on Linux you get the same behavior.

eabase commented 2 years ago

Yes, I know, but that is not very user friendly. Would have preferred a method to link one to the other.

This seem to work:

To create symbolic links of the Administrator user's filepos_history and .nanorc to the real ones,
do the following (from an elevated shell):

New-Item -ItemType SymbolicLink -Path "C:\ProgramData\.local\share\nano\filepos_history" -Target  "C:\Users\<username>\.local\share\nano\filepos_history" -Force
New-Item -ItemType SymbolicLink -Path "C:\ProgramData\.nanorc" -Target  "C:\Users\<username>\.nanorc" -Force

Closing issue for now.

lhmouse commented 2 years ago

Actually symlinks are preferred too on Linux. BTW you could have used the mklink utility to create symlinks.

eabase commented 2 years ago

Thanks, but I avoid the CMD like the COVID plague.

lhmouse commented 2 years ago

I don't like Windows either, but it is not a legitimate reason to break up with it.