Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

files in config get overwritten #694

Closed
jankatins opened this issue Nov 5, 2015 · 14 comments
Closed

files in config get overwritten #694

jankatins opened this issue Nov 5, 2015 · 14 comments

Comments

@jankatins
Copy link
Contributor

jankatins commented Nov 5, 2015

I my case it's problematic for aliases but the other files might also be problematic. IMO config should be empty apart form a readme.md file and either be populated by vendor\init.bat or cmder itself.

Only the conemu.xml file is overwritten, everything else is generated on first start.

@jankatins
Copy link
Contributor Author

I think at least two things should be moved out of the config dir: aliases and cmder.lua.

For the latter it's I think the easiest to move it to vendor/cmder.lua and add a line to load the file which loads config/config.lua if it exist.

Not sure what to do about the aliases file, if it is cmd only, it could be copied in init.bat

@daxgames
Copy link
Member

Is it possible for the config/aliases file to stay where it is so the cmder team can include 'default' aliases and also the use of a user-aliases file in the config folder that is loaded after the config/aliases if it exists not overwritten on update.

The alias.bat file would need to be modified to add user aliases to config/user-aliases instead of config/aliases.

Not even sure if it is possible, I'm not a doskey guru, but this provides the best of both worlds.

@jankatins
Copy link
Contributor Author

I currently use config\aliases_jasc and source that in my user_startup.bat file. AFAI understand it, the current aliases are examples, not things the user should have/ are needed by cmder.

IMO: move the current config\aliases file to vendor\aliases.example and let vendor\init.bat copy that to the config dir, if it does not exist. And then let doskey load it.

This was referenced Nov 24, 2015
@jankatins
Copy link
Contributor Author

If #736 gets merged, only ConEmu.xml and settings are in there. Not sure how to handle them, if it should go the same way as #735/#736, then cmder.exe must do the copy.

But on the other hand, I've actually no idea how the ConEmu.xml file is handled (#695 and #427). And actually, after the changes in the new release, I don't think I have to do anything in this files, so I'm fine after these two PRs :-)

@daxgames
Copy link
Member

What do you guys think of my suggestion of having a cmder team controlled aliases file that is loaded first then a config\user-aliases file that is loaded second? This would require making the bin\alias.bat manage config\user-aliases.

I have verified this would work and it is an easy change.

I have about a lot of aliases, mostly Git related, that make most Git commands 1-5 characters for both cmd and bash. I could also look at making these work Powershell. It would be nice to add these to Cmder.

A user could override any included macro with his own by adding it to the config/user-aliases, config/user-profile.ps1, or config/user-profile.sh.

Edit: Unfortunately Powershell's new-alias and set-alias are lame and cannot make aliases that have command line arguments. So really useful Powershell aliases are not likely to happen.

@jankatins
Copy link
Contributor Author

I'm against a cmder controlled alias file if you couldn't "unalias" any alias in it.

@jankatins jankatins mentioned this issue Nov 26, 2015
@daxgames
Copy link
Member

ConEmu.xml could be handled I a similar way I am handling cmder.sh and similarly to the way you handled aliases. There could be a default vendor/conemu.xml.default file that is copied to the config dir by Cmder.exe if it does not already exist before it launches ConEmu.exe. This requires changes to cmder.exe that I cannot do or I would and create a PR. Somebody? :-)

This plus your cmder.lua suggestion just leaves the settings file to deal with. Not even sure what it does but it could be handled in a similar way as well leaving the config/ dir a create on demand and purely for user config that is never overwritten. I like it.

@rmorrin
Copy link
Contributor

rmorrin commented Nov 27, 2015

I have about a lot of aliases, mostly Git related, that make most Git commands 1-5 characters for both cmd and bash.

@daxgames Sorry to hijack the thread, but how do you manage aliases for both cmd and bash on Windows? I currently switch between both frequently (from within cmder of course) and up until now have been duplicating aliases; once in config/aliases and once in a .aliases file in my home directory (which I source in .bashrc). I'd love to find a cleaner way of doing this!

@MartiUK
Copy link
Member

MartiUK commented Nov 27, 2015

Same for PowerShell as well really, should we keep the doskey syntax and write something to parse it for bash and Ps? Or have something completely different?

@daxgames
Copy link
Member

@rmorrin I am right there with you. I currently have two files. One for bash and one for cmd. Powershell aliases suck so they will never be as functional as cmd/sh.

@daxgames
Copy link
Member

@MartiUK - I think coding some bash to parse the config/aliases file and convert it to bash aliases would not be too tough as long and that file did not contain any Doskey special characters like $B, $G, $L, $T $$, and $*.

The problems I see are not all macros will work in bash and cmd and if you want to save macros in bash you would have to manually edit the config/aliases files in doskey format. Just seems clunky and error prone. Powershell aliases can only alias a single command with no arguments to a single probably shorter command so it is pointless to worry about converting doskey/sh aliases to Powershell. They just do not work right.

@Jackbennett
Copy link
Contributor

Powershell aliases can only alias a single command with no arguments to a single probably shorter command so it is pointless to worry about converting doskey/sh aliases to Powershell. They just do not work right.

Correct and I agree but there's nothing to stop you just making a function in the PS profile that does the alias you require. You can even make a nice descriptive named function and alias that to type in.

i.e I have:

function get-list{
    get-childitem @args | format-wide -autosize
}
Set-Alias lsa get-list

#...other things
# CD to my projects folder at startup
lsa -Directory

more examples, albeit an old file now noteworthy: touch, swap-python or from my other file git-server

@jankatins
Copy link
Contributor Author

Current status (for cmd): Only the conemu.xml file is overwritten, everything else is generated on first start.

@daxgames
Copy link
Member

daxgames commented Oct 4, 2016

@JanSchulz PR#1109 - Addresses the above by backing up the ./vendor/conemu-maximus5/conemu.xml file if it exist at startup to ./config/ConEmu-%COMPUTERNAME%.xml OR ./config/user-ConEmu.xml if one or the other already exists in that order.

If neither exists the backup will default to ./config/user-ConEmu.xml this maintains a portable copy of changes made to this file while using cmder that will persist across new installs and updates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants