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

Is it possible to show the current folder in front of cursor on the current line? #338

Closed
kirkouimet opened this issue Dec 2, 2014 · 9 comments

Comments

@kirkouimet
Copy link

Is it possible to mimic the standard cmd.exe behavior by keeping the cursor on the same line as the current folder, e.g.,

C:\Folder _

capture

@fredericseiler
Copy link

You can change the prompt style in your cmder\vendor\init.bat.

image

  • If you want the default Windows cmd prompt, just replace it with @prompt $P$G.
  • If you want to keep the "advanced" Cmder prompt, but without the line break, remove the $S$_ part.

image

@kirkouimet
Copy link
Author

Thanks!

@miparnisari
Copy link

Where is that line in the latest version? I cannot find it :(

@fredericseiler
Copy link

Starting from Cmder 1.3.0, you will find the prompt definition in vendor\clink.lua (function set_prompt_filter()) if you're using a cmd task, or in vendor\profile.ps1 (function global:prompt) if you're using a PowerShell task.

If you want to properly override the prompt in a cmd task, just add your own prompt.lua in the config folder with this definition :

function my_prompt_filter()
    cwd = clink.get_cwd()
    prompt = "\x1b[1;32;40m{cwd} {git}{hg} \n\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)

You can then customize the prompt without loosing it when updating Cmder.

@jalovatt
Copy link

New user, not familiar with terminal stuff at all other than some mandatory DOS usage to play games under Windows 3.1 when I was a kid.

Like the OP, I'm used to a single-line prompt, so I tried the Lua example above. It worked, but it also removed all text coloring from the terminal. So I deleted the .lua file, but the coloring hasn't come back. I tried putting the file back and fiddling with the prompt it defines, but nothing I do makes a difference. Likewise, editing init.bat doesn't seem to do anything.

How do I fix this and/or get what I was originally aiming for - single-line prompt with coloring?

I'm sure the problem here is one of those between-keyboard-and-chair deals. Cheers.

@noxasch
Copy link

noxasch commented Jan 2, 2019

For current version (i downloaded on 1 January 2019):

In C:\YOUR_PATH\cmder\vendor\ edit the clink.lua file, just remove the "\n" in the string for cmder_prompt which in my case it was at line 50,

-- local cmder_prompt = "\x1b[1;32;40m{cwd} {git}{hg}{svn} \n\x1b[1;39;40m{lamb} \x1b[0m"
local cmder_prompt = "\x1b[1;32;40m{cwd} {git}{hg}{svn} \x1b[1;39;40m{lamb} \x1b[0m"
 -- local lambda = "λ"
local lambda = "$"

note: the commented one is the original one.

@daxgames
Copy link
Member

daxgames commented Jan 6, 2019

@noxasch Not a good solution as it will be overwritten on update. Instead add the below to a file called %cmder_root%\config\my_prompt.lua:

function my_prompt_filter()
    cwd = clink.get_cwd()
    prompt = "\x1b[1;32;40m{cwd}{git}{hg}{svn}\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)

@gabrielfsousa
Copy link

gabrielfsousa commented Jan 21, 2019

i'm trying to change the prompt on Version 1.3.11.843, like @noxasch and @daxgames but theres no change.... what i'm doing wrong ?

SORRY:
im using powerline that why was not change anything.

@Kotsuha
Copy link

Kotsuha commented Apr 22, 2020

The above my_prompt_filter() approach is great and I've successfully changed the "λ" symbol. However it makes non-ASCII path characters garbled because

clink.get_cwd() is returning a string which is differently encoded than what
clink.prompt.value expects.

as mentioned in #1070.

If I cd to a non-ASCII path it looks like this

D:\PortableApps\Cmder (master)
★ cd "D:\Temp\あいうえお"

D:\Temp\?????
★

How can I solve this? I've looked into the %cmder_root%\vendor\clink.lua file (not familiar with Lua though) and figured maybe I need to cache the original cwd. But if modification to original file is needed then the benefit of creating a new file is gone.

Cmder Version 1.3.14.982

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

8 participants