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

Embed 'alias' functionality into 'vendor\bin' and Load User Lua files #1871

Merged
merged 28 commits into from
Sep 13, 2018

Conversation

daxgames
Copy link
Member

@daxgames daxgames commented Sep 1, 2018

Fix #1862 - 1.3.6: Error on start path with trailing slash in quotes.

Enable/Disable Cmder features by detected comspec

  • Add vendor\lib\lib_base function cmder_shell that sets 3 new env vars"

    • CMDER_SHELL = [cmd|tcc|tccle]
    • CMDER_CLINK = [1|0] Default = 1 or On
    • CMDER_ALIASES = [1|0] Default = 1 or On
  • vendor\init.bat uses the new variables to determine whether to configure/load certain features at startup.

Move bin\alias.bat to vendor\bin\alias.cmd

Cmder's 'alias' command has been moved into '%CMDER_ROOT%\vendor\bin\alias.cmd'
to get rid of this message either:

Delete the file '%CMDER_ROOT%\bin\alias.bat'

or

If you have customized it and want to continue using it instead of the included version
  * Rename '%CMDER_ROOT%\bin\alias.bat' to '%CMDER_ROOT%\bin\alias.cmd'.
  * Search for 'user-aliases' and replace it with 'user_aliases'. 
)

Loads user *.lua files after %cmder_root%/vendor/clink.lua

  • Loads *.lua from the following sources in order:

    • %cmder_root%/vendor/clink.lua
      • %cmder_root%/vendor/clink-completions/*.lua
      • %cmder_root%/config/*.lua
      • [cmder_user_config_root]/*.lua If specified at launch using -c [cmder_user_config_root]
  • Allows user more control over clink settings. %cmder_root%/config/prompt.lua example:

function my_prompt_filter()
    cwd = clink.get_cwd()
    prompt = "\x1b[1;32;40m{cwd}{git}{hg}\x1b[1;30;40m{lamb} \x1b[0m"
    new_value = string.gsub(prompt, "{cwd}", cwd)
    clink.prompt.value = string.gsub(new_value, "{lamb}", "λ")
end

clink.prompt.register_filter(my_prompt_filter, 1)

Produces a prompt like:

C:\Users\dtgam\cmderdev(user_lua -> origin)λ

instead of:

C:\Users\dtgam\cmderdev (user_lua -> origin)
λ

@daxgames daxgames changed the title Load User Lua files Embed 'alias' functionality into 'vendor\bin' and Load User Lua files Sep 1, 2018
@daxgames daxgames requested a review from Stanzilla September 1, 2018 22:37
@Stanzilla
Copy link
Member

Very nice, especially the prompt stuff, that was requested pretty often, should probably be on the wiki somewhere as well after this has been merged. Have not tested it yet but the code looks fine

@daxgames
Copy link
Member Author

daxgames commented Sep 2, 2018

I actually wrote the lua stuff months ago. I've just been having fun this weekend working on stuff that's not work.

@daxgames
Copy link
Member Author

daxgames commented Sep 2, 2018

I also figured out how to fix the clink prompt defaulting ot origin as a remote when its a local only repo.

Think I'm gonna working the git prompt colors thing next. This was merged into clink-completions

vendor/init.bat Outdated
)

:: Pick right version of clink
echo here
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DOH! Should be removed

@DRSDavidSoft
Copy link
Contributor

Nice work on fixing #1862, and thanks for completing #1695's discussion!

@Stanzilla
Copy link
Member

@daxgames how done are you with this PR?

@daxgames
Copy link
Member Author

Yes

@Stanzilla Stanzilla merged commit 0d2e16c into cmderdev:master Sep 13, 2018
@daxgames daxgames deleted the user_lua branch September 16, 2018 21:17
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

Successfully merging this pull request may close these issues.

3 participants