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

Add support for turning off cursor blink #1379

Open
Tracked by #15746
KiYugadgeter opened this issue Jun 22, 2019 · 63 comments
Open
Tracked by #15746

Add support for turning off cursor blink #1379

KiYugadgeter opened this issue Jun 22, 2019 · 63 comments
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Help Wanted We encourage anyone to jump in on these. Issue-Task It's a feature request, but it doesn't really need a major design. Priority-2 A description (P2) Product-Terminal The new Windows Terminal.
Milestone

Comments

@KiYugadgeter
Copy link

I don't link blinking cursor on terminal.
so I have tried to stop blink of cursor from settings but there is no option to do it.
How to disable blink of cursor?

@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Jun 22, 2019
@leptr
Copy link

leptr commented Jun 22, 2019

I just set the cursor color to match the background color so it would be invisible, I couldn't find any other way to either remove it or stop it from blinking, but I hope this helps you

@Lo0oG
Copy link

Lo0oG commented Jun 22, 2019

Go into the Control Panel and search for Blink.

@AeliusSaionji
Copy link

Seconding a request for this setting.

@DHowett-MSFT DHowett-MSFT changed the title How I can stop blink of cursor in Windows Terminal? Add support for turning off cursor blink Jun 24, 2019
@DHowett-MSFT DHowett-MSFT added Area-Settings Issues related to settings and customizability, for console or terminal Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Help Wanted We encourage anyone to jump in on these. Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal. labels Jun 24, 2019
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Jun 24, 2019
@DHowett-MSFT DHowett-MSFT added Needs-Tag-Fix Doesn't match tag requirements and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Jun 24, 2019
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Jun 24, 2019
@leptr

This comment has been minimized.

@DHowett-MSFT

This comment has been minimized.

@leptr

This comment has been minimized.

@KiYugadgeter
Copy link
Author

You could see here.
#1294 (comment)

@AeliusSaionji
Copy link

@dkter
Copy link
Contributor

dkter commented Jun 30, 2019

The cursor blinking can be turned off (system-wide) by going to Keyboard Properties in the Control Panel and turning the cursor blink rate all the way down:

image

Would it be useful to disable the cursor blinking for just the terminal app?

@zadjii-msft zadjii-msft added this to the Terminal Backlog milestone Jul 1, 2019
@KiYugadgeter
Copy link
Author

KiYugadgeter commented Jul 2, 2019 via email

@SCWells72
Copy link

Agreed that this should be a distinct option just for the terminal app. Here's how it can be configured in mintty:

image

Note the distinct config fields for cursor shape and whether to blink.

@KiYugadgeter
Copy link
Author

KiYugadgeter commented Jul 3, 2019

@DHowett-MSFT I've tried write some code to disable it.
But it looks like there are some error.

  1. IDE has indicated redefinition of method definition of UseBlinkCursor in TerminalSettings.cpp despite I have defined just one time
  2. IKeyBindings, IKeyChord in cascadia\TerminalApp\AppKeyBindings.idl unresolved type declaration.

How to fix it?

https://github.com/KiYugadgeter/terminal/tree/my_build

@hwo411
Copy link

hwo411 commented Aug 18, 2019

Any ETA to add this?

@zadjii-msft
Copy link
Member

@hwo411 Nope - It's marked as "Terminal Backlog", which means we don't think we're going to get to it ourselves before we release a 1.0 version of the terminal.

It's also marked "Help-Wanted", so if someone's feeling particularly passionate about this, they should feel free to build a solution themselves, and we'd happily review a PR 😉

@hwo411
Copy link

hwo411 commented Sep 5, 2019

@zadjii-msft thanks for explanation!

@ghost ghost added the In-PR This issue has a related PR label Sep 25, 2019
@LoganDark
Copy link

Still waiting on this. A cursor blink is extremely obnoxious while looking at the terminal and trying to read text, Windows Terminal is still extremely limited in its customization options and basic features like this should not be backlogged. Please reconsider your stance on this, cursor blink in text boxes has nothing to do with cursor blink in terminals, so my terminal blink should not be controlled by that global setting.

@divijan
Copy link

divijan commented Jul 5, 2021

For those wondering, the easiest way I've found to disable the blinking cursor is by putting echo -e -n "\e[2 q" at the end of your .bashrc/.zshrc file (or Write-Host -NoNewLine "`e[2 q" at the end of your profile.ps1 for PowerShell users). This way, they get called upon startup. As a bonus, the -n/-NoNewLine flag removes the extra new line that appears on startup which bugged me a little.

worked like charm on Ubuntu WSL2 👍 Thanks

@willchao612
Copy link

willchao612 commented Jul 16, 2021

Is there any workaround here yet without changing my shell startup file? I tried it and it smh broke some of my vim plugins. PLZ make it a customizable options for WT.😢

@zeroxia

This comment has been minimized.

@Avi0
Copy link

Avi0 commented Jul 21, 2021

The workaround is to disable cursor blinking system-wide and disable taskbar animations in System Properties, Advanced, Visual Effects (to avoid stuck icon highlighting in the taskbar).

@willchao612
Copy link

It's weird that I have done nothing and it just stopped blinking anymore since today.

@willchao612
Copy link

It's weird that I have done nothing and it just started blinking again since today.

@LoganDark
Copy link

@willchao612 A story in two comments...

@willchao612
Copy link

Finally got a solution. If you are using tmux and this cursor blinking issue happens, put the following line in your .tmux.conf and restart your tmux session.

set -sa terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[ q'

Found this by chance when solving another cursor shape issue in Neovim. Docs here. I hope it helps you guys.

@zakutin
Copy link

zakutin commented Sep 6, 2021

It's weird that I have done nothing and it just stopped blinking anymore since today.

I noticed the following:

  • launch wt, cursor is blinking
  • run neovim (by default the cursor is not blinking in neovim)
  • exit neovim
  • cursor is not blinking in wt command line
  • restart wt, cursor is blinking again

@willchao612
Copy link

@zakutin Did you manually set TERM in you startup file? If so, try commenting it out and restart tmux.

@zadjii-msft
Copy link
Member

FWIW This probably got better in some ways in #10543/#10589, and worse in others: #10754

@zadjii-msft zadjii-msft modified the milestones: Terminal v2.0, 22H2 Jan 4, 2022
@zadjii-msft zadjii-msft added the Priority-2 A description (P2) label Jan 4, 2022
@ZYinMD
Copy link

ZYinMD commented May 18, 2022

Hey guys, maybe a dumb question but: does the cursor in Linux blink by default?

I use the cursor shape to remind myself where I am - in cmd and pwsh I use a blinking underscore, in git bash I use a blinking pipe, in WSL I use a block. Those are their original default shapes, so I try to keep them.

So, now the question is, if I want my Ubuntu to look authentic, should I make the block blink or not blink?

@niask11
Copy link

niask11 commented May 18, 2022

Hey guys, maybe a dumb question but: does the cursor in Linux blink by default?

In Ubuntu Desktop it's a block and it doesn't blink as far as I remember...

@dkter
Copy link
Contributor

dkter commented May 18, 2022

@ZYinMD in GNOME Terminal (the default terminal in Ubuntu) the cursor is a blinking solid block, in the TTY (i.e. if you run Ubuntu without a GUI) it's a blinking underscore

@mataha
Copy link

mataha commented May 12, 2023

Hi! For those subscribed to this thread and many more coming from search results like me, I have a cmd.exe solution ready.

The code
@setlocal EnableDelayedExpansion EnableExtensions & set "CMD=!CMDCMDLINE!" 2>nul
@if /i not "!CMD!"=="!CMD:/=!" (goto :EOF) else @if not defined DEBUG (echo off)

for /f "usebackq" %%E in (`echo(prompt $E^| "%ComSpec%" /d /q "" 2^>nul`) do (
    echo(%%~E[?12l %%~E[3A %%~E[3M %%~E[1A
)

Save the above to ~\.cmd as UTF-8, then run:

set PROCESSOR_ARCHITECTURE | "%SystemRoot%\system32\find.exe" "64" >nul && (
    set "registry_view=64") || set "registry_view=32"

reg add "HKCU\Software\Microsoft\Command Processor" ^
    /v "AutoRun" /t "REG_EXPAND_SZ" /f /reg:%registry_view% ^
    /d "@if exist """^%USERPROFILE^%\.cmd""" """^%USERPROFILE^%\.cmd""""
Explanation

From Console Virtual Terminal Sequences: ESC [ ? 12 l disables text cursor blinking. The problem is then twofold:

  • emit said sequence within a terminal
  • make the operation persistent on startup

There are many ways of generating ESC within cmd.exe, but the cleanest method involves printing it with the prompt internal command:

for /f "usebackq" %%E in (`echo(prompt $E^| "%ComSpec%"`) do set esc=%%~E
  1. prompt $E sets the current prompt to an ESC character.
  2. echo that command and pipe it to the default command interpreter (cmd.exe) that's stored in a global environment variable ComSpec to make it set a new prompt and output it. Why echo with an unclosed parenthesis? For a multitude of good reasons.
  3. Execute the above in a subshell (within backticks, like other commonplace shells) and store the output in a for /f variable named E. As the contents of the command are going to be evaluated again, that | has to be escaped. The tilde is technically not necessary (it serves the purpose of removing surrounding double quotes), but is considered good practice.
  4. As that is going to run within a context of a batch script, double all the %s.

With ESC in a variable we're free to disable blinking permanently:

echo(%esc%[?12l %esc%[3A %esc%[3M %esc%[1A

In order:

  1. Do what we came here for. This will spew some rubbish to the buffer. (todo control execution order)
  2. Move the cursor up by three lines so that all of the crap printed is either below or on the same line.
  3. Erase 3 lines from the buffer starting from the position we're on, cleaning up the screen.
  4. Finally, move the cursor up by a line. This is not necessary, but it will cleanly separate prompt from startup information when the control returns.

From here we're off to making said changes persistent - with cmd.exe's help (literally - cmd /?):

If /D was NOT specified on the command line, then when CMD.EXE starts, it
looks for the following REG_SZ/REG_EXPAND_SZ registry variables, and if
either or both are present, they are executed first.

    HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun

        and/or

    HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun

Make the content of that registry variable execute a script of our choice if it exists:

set PROCESSOR_ARCHITECTURE | "%SystemRoot%\system32\find.exe" "64" >nul && (
    set "registry_view=64") || set "registry_view=32"

reg add "HKCU\Software\Microsoft\Command Processor" ^
    /v "AutoRun" /t "REG_EXPAND_SZ" /reg:%registry_view% ^
    /d "@if exist """^%USERPROFILE^%\.cmd""" """^%USERPROFILE^%\.cmd""""

Such file probably isn't present yet, so create a .cmd file in the current user's home directory:

type nul >"%USERPROFILE%\.cmd"

And populate it with the following:

@setlocal EnableDelayedExpansion EnableExtensions & set "CMD=!CMDCMDLINE!" 2>nul
@if /i not "!CMD!"=="!CMD:/=!" (goto :EOF) else @if not defined DEBUG (echo off)

for /f "usebackq" %%E in (`echo(prompt $E^| "%ComSpec%" /d /q "" 2^>nul`) do (
    echo(%%~E[?12l %%~E[3A %%~E[3M %%~E[1A
)

Take note that this script will run every time an instance of cmd.exe starts. That involves all subshells, including both the one we're getting an ESC character from and the one wrapping the whole command. To prevent that, we're creating a kind of a header guard in the first two lines - it will exit immediately if the currently executing command contains slashes (as subshells are basically cmd /c <backtick_content>). That doesn't involve the instance we're piping the prompt command to, thus a /d switch is added to prevent it from executing any startup scripts.

todo debugging machinery, explanation of delayed expansion and cmd /q 2>nul, exit label, @ operator, sleep

Preview
cmd.mp4

@GeekDuanLian
Copy link

For those using bash, add this to your ~/.bashrc:
printf '\e[?12l'

@lost22git
Copy link

For those using WindowsPowerShell/pwsh, add this to your $PROFILE

echo "`e[?12l"

@abhbh
Copy link

abhbh commented Aug 17, 2024

For Nushell users, add the following to your config.nu

print "\e[?12l"

@densalo
Copy link

densalo commented Aug 17, 2024

On windows 10 with windows terminal 1.20.11781.0 and PowerShell 7.4.4
I have not been able to stop cursor blinking.
I've tried all forms of e[ but it doesn't seem to do anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Help Wanted We encourage anyone to jump in on these. Issue-Task It's a feature request, but it doesn't really need a major design. Priority-2 A description (P2) Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging a pull request may close this issue.