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

How to override autorun for clink? #663

Closed
GameLord2011 opened this issue Aug 18, 2024 · 14 comments
Closed

How to override autorun for clink? #663

GameLord2011 opened this issue Aug 18, 2024 · 14 comments
Labels
question Question about something

Comments

@GameLord2011
Copy link

I cannot find a command to close this.

@chrisant996
Copy link
Owner

Are you asking how CMD.exe works? Are you looking for the exit command? If so, this has nothing to do with Clink.

@chrisant996 chrisant996 added the needs more information The issue needs clarifying information label Aug 18, 2024
@GameLord2011
Copy link
Author

GameLord2011 commented Aug 18, 2024 via email

@GameLord2011
Copy link
Author

GameLord2011 commented Aug 18, 2024 via email

@GameLord2011
Copy link
Author

GameLord2011 commented Aug 18, 2024 via email

@chrisant996
Copy link
Owner

Oh, you have Clink configured for AutoRun so that it gets injected into every cmd.exe, but you want to be able to disable Clink sometimes.

There are several ways to temporarily disable Clink after it's been injected.

Here are three examples:

  • You can set CLINK_NOAUTORUN=1 and then start cmd.exe, and the new instance of cmd.exe will not have Clink.
  • You can use the noclink.cmd script that comes with clink-gizmos to disable the prompt filtering.
  • You could use a more sophisticated Lua script for loading oh-my-posh, which could define a setting for enabling/disabling oh-my-posh. The oh-my-posh instructions don't mention that, because it's more complicated than the tiny simple script in the instructions.

If you replace your existing oh-my-posh Lua script with the following script, then you can turn off oh-my-posh in future sessions by running clink set ohmyposh.enable false. It can't disable oh-my-posh in the current session, because the scripts built into oh-my-posh don't support that -- but it's something you could request in the oh-my-posh repo.

Alternative oh-my-posh.lua script:

settings.add("ohmyposh.enable", false, "Enable oh-my-posh prompt filter.", "Takes effect on next session.")
settings.add("ohmyposh.theme", "", "The oh-my-posh theme to use.")
settings.add("ohmyposh.exepath", "", "Path to oh-my-posh program.", "Specifies where to find the oh-my-posh program.\nCan be used when it isn't on the system search PATH.") -- luacheck: no max line length

if not settings.get("ohmyposh.enable") then
    if rl.getbinding then
        if rl.getbinding(' ') == '"luafunc:ohmyposh_space"' then
            rl.setbinding(' ', 'self-insert')
        end
    end
    return
end

local init_script = os.getenv("CLINK_OHMYPOSH_INIT_SCRIPT")
if init_script then
    loadfile(init_script)()
else
    local theme = settings.get("ohmyposh.theme") or ""
    if theme ~= "" then
        theme = ' -c "' .. theme .. '"'
    end
    local exe = settings.get("ohmyposh.exepath")
    if not exe or exe == "" then
        exe ="oh-my-posh.exe"
    end
    local script = io.popen('2>nul "' .. exe .. '" init cmd' .. theme):read("*a")
    if script == "" then
        print('Unable to get oh-my-posh script from "' .. exe .. '".')
    else
        load(script)()
    end
end

@chrisant996 chrisant996 added question Question about something and removed needs more information The issue needs clarifying information labels Aug 18, 2024
@chrisant996 chrisant996 changed the title Cannot close clink How to override autorun for clink? Aug 18, 2024
@GameLord2011
Copy link
Author

GameLord2011 commented Aug 18, 2024 via email

@GameLord2011
Copy link
Author

GameLord2011 commented Aug 18, 2024 via email

@GameLord2011
Copy link
Author

GameLord2011 commented Aug 18, 2024 via email

@GameLord2011
Copy link
Author

GameLord2011 commented Aug 18, 2024 via email

@GameLord2011
Copy link
Author

GameLord2011 commented Aug 18, 2024 via email

@GameLord2011
Copy link
Author

GameLord2011 commented Aug 18, 2024 via email

@GameLord2011
Copy link
Author

GameLord2011 commented Aug 18, 2024 via email

@GameLord2011
Copy link
Author

thanks!

@chrisant996
Copy link
Owner

where is clink_no autorun?
how do i define it?

You'd use the CLINK_NOAUTORUN environment variable the way I said in the earlier comment:

set CLINK_NOAUTORUN=1
start cmd.exe

if i define the no autorun variable will it only run if i enter the clink
command?

All that CLINK_NOAUTORUN does is make the autorun script do nothing.

Everything else works as usual.

Refer to Using Clink for details on how to start Clink.

How do I configure the autorun to use noclink.cmd?

In a cmd.exe where Clink is already running, you run the noclink.cmd script.

If the script's directory isn't in the system PATH (it probably won't be), then you need to give the full path to it.

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

No branches or pull requests

2 participants