Hyper: "clear" broken on Windows when using with Git BASH

Created on 20 Feb 2017  ยท  45Comments  ยท  Source: vercel/hyper

  • OS version and name: Windows 10 version 1607 build 14393.693
  • Hyper.app version: 1.2.1
  • Link of a Gist with the contents of your .hyper.js: link
  • Relevant information from devtools: N/A
  • The issue is reproducible in vanilla Hyper.app: Is Vanilla

Issue

I've set up Hyper on Windows to use the bash that comes bundled with Git for windows, however when I run the clear command, the contents of the window is not cleared, though the prompt does move back to the top of the screen, over the top of the pervious content.

Bug Windows

Most helpful comment

TERM=msys did not work for me, however TERM=cygwin did :)

All 45 comments

I was having all kinds of various problems writing to the screen until I set the environment var TERM=msys. I think it was set to cygwin which worked in 1.1.0. Maybe that will help?

@jmcmellen Solved it for me, thanks.

TERM=msys did not work for me, however TERM=cygwin did :)

+1
thx for workaround @keirlawson @jmcmellen

Was having the exact same issue.

Now I'm using the command reset, it also does what clear is supposed to!

Sorry guys I'm pretty new in this, but where i can change that TERM="" variable?

@TheMartes ~/.hyper.js

@jmcmellen Thanks that worked!

If someone is looking to actually clear the screen (not just scroll down) in bash, here's how:

alias cls="echo -e '\\0033\\0143'"

Then, just type cls.

I tried with TERM:'msys' and TERM:'cygwin', but neither clear the screen. It just moves the cursor back to the top. Any other suggestions to fix this?

@math2001 Thank you! It's useful!

@MSaIim what platform are you on? are you using bash from Git On Windows as well?

@vuongggggg: you're welcome! ๐Ÿ™‚

@math2001 I am on Windows 10 64bit and yes I am use bash from Git on Windows.

Did you restarted hyper? did you added TERM: 'cygwin' in the env object?

Thank you very much! I didn't put it inside the env object. Thought it was another variable. Works great now.

Glad I could help! Could a collaborator or the owner add a tag like has-workaround to this thread please?

@math2001 Why does your workaround work? Why the extra escaped characters?

alias cls="echo -e '\\0033\\0143'"

let gitRootFolder = 'C:\\Users\\${yourName}\\AppData\\Local\\Programs\\Git';

Setting the TERM environment variable to cygwin || msys didn't work for me. My fix was instead of using ${gitRootFolder}\bin\bash.exe, I used ${gitRootFolder}\usr\bin\bash.exe. That one worked for me without a hitch!

YES!! This trick seems to make ctrl+c work properly too! Thanks a lot @cnswico!! ๐ŸŽ‰ ๐Ÿ‘ ๐Ÿ˜„

@geekosupremo the escape characters are the ANSI escape sequence for resetting the terminal "ESC c" You could also write it as:

alis cls="echo -e '\\0033c'"

In general, I would expect clear to do precisely this, but I suppose that it is possible that, if the TERM variable were set incorrectly, it might do something else (for instance if it thought you were using a line or dumb terminal).

Also, I would set TERM to xterm-256color which is what most terminal emulators that support 256 color set it to.

Or, for that matter xterm. Hyper is an xterm emulator after all.

Also, for those of you having problems, it would be helpful to know what you have $TERM set to. The output of:

echo $TERM

would help anyone debugging this issue.

Also, you might want to check your terminal init files to see if they are setting it incorrectly.

I'm losing my text from time to time and I have to do a reset

my $TERM = cygwin

@christianwico

let gitRootFolder = 'C:\Users\${yourName}\AppData\Local\Programs\Git';
Setting the TERM environment variable to cygwin || msys didn't work for me. My fix was instead of using ${gitRootFolder}\binbash.exe, I used ${gitRootFolder}\usr\binbash.exe. That one worked for me without a hitch!

Can you explain where to put this info? I am not clear.

You place it in your .hyper.js file. You can get to it by opening Hyper and pressing Ctrl + Comma.

Alternatively, you may find the file in your User directory (C:\Users\YourName) and open it using a text editor of your choice.

In the .hyper.js file, look for the shell key and assign the path (which should be C:\Users\YourName\AppData\Local\Programs\Git\usr\bin\bash.exe) I specified. Save the file and reload Hyper.

@christianwico still doesn't seem to work. I don't have that bash.exe in that specific path, but it's here: C:\Program Files\Git\usr\bin\bash.exe, but doesn't seem to work. -- just crashes.

I came here to find this because tools like top and nano were not clearing the screen when rendering, so previous console output was bleeding through anywhere there was space.

Thank you so much for the TERM:"cygwin" solution. Mine was "xterm-256color" by default. (Also using Hyper with Git for Windows bash and Cygwin.)

For Windows 10 users, in Hyper:

โ˜ฐ > Edit > Preferences...

Add/update the following lines:

    // the shell to run when spawning a new session (i.e. /usr/local/bin/fish)
    // if left empty, your system's login shell will be used by default
    // make sure to use a full path if the binary name doesn't work
    // (e.g `C:\\Windows\\System32\\bash.exe` instead of just `bash.exe`)
    // if you're using powershell, make sure to remove the `--login` below
    shell: 'C:\\Program Files\\Git\\git-cmd.exe',

    // for setting shell arguments (i.e. for using interactive shellArgs: ['-i'])
    // by default ['--login'] will be used
    shellArgs: ['--command=usr/bin/bash.exe', '-l', '-i'],

    // for environment variables
    env: {
      TERM: 'cygwin'
    },

I'm also still getting issues with the screen buffer failing to clear, tried setting TERM to a variety of different things, nothing seems to work :(

Using the latest version of Hyper, are there any other methods to getting this work?

Just trying to get Hyper and zsh to work on Windows..

Ha! Thanks!

env: {
  TERM: 'msys'
}

Neither 'mysys' nor 'cygwin' are helping with the clear issue

(Windows 10 Fall Creators Update)

Any update since Fall Creators Update?

The 'cygwin' solution is currently working for me on Windows 10 version 1709 (Fall Creators Update).

env: {
  TERM: 'cygwin'
}

@hermbit the 'cygwin' solution works, but then we lose 256 color support (the colors set up on my PS1 are gone when using TERM: 'cygwin' as opposed to TERM: 'xterm-256color'. Is there any workaround?

๐Ÿ‘ on losing 256 colors with TERM: cygwin or msys.

I was having the same issue using clear with Hyper hooked up to Cmdr on Windows 10.
Easiest way I found was to do a ctrl shift k. Works like a charm.
Sorry if someone else has already said this!

Work around for win10

Install hyper-startup extension
npm install -g hpm-cli
hpm install hyper-startup

Add alias commands
Edit config and add the following

module.exports = {
  config: {
    ...
    commands: ['alias clear="echo -e \'\\0033\\0143\'"', 'clear'],
  },
  ...
};

Microsoft Windows [version 10.0.17134.590]

Set env to cygwin works perfectly for me ;) thx @michaelauderer

        env: {
            TERM: 'cygwin'
        }

Has there been a regression here? TERM=cygwin fixes the problem for Hyper 2.1.2, but the issue appears to be back in Hyper 3.0.0-canary.8.

EDIT: Whoops, it looks like it's not the same issue. In the issue I am currently experiencing, TERM=cygwin doesn't fix it, and if you type 'clear' and then click anywhere inside the window, the clear will work. In issue #1559, clicking won't do anything, and the issue is fixed by TERM=cygwin.

Hyper 3 now doesn't clear the screen, so I have to downgrade to 2. It only clears when clicking on it, but it is very unconvenient.

@talentlessguy make sure your Hyper config has been updated. Hyper 3 uses a different config location and ships with a default config. https://github.com/zeit/hyper/issues/3605

Any update on this?
I am having the same issue as reported by @robrtsql and @talentlessguy . Clicking anywhere inside the window clears the screen, but thats very inconvenient.

My hyper config is updated at C:\Users\<username>\AppData\Roaming\Hyper.
Hyper version I am using: 3.0.2 (stable)

Also, I would set TERM to xterm-256color which is what most terminal emulators that support 256 color set it to.

Absolutely - I set TERM to xterm-256color in ~/.bashrc as well... That way I have a consistent experience in ssh. However, I think the issue is that /usr/bin/clear isn't sourcing terminfo correctly on msys. However, /usr/bin/clear can also take a term argument...

Using an alias seemed to do the trick for me... alias clear="clear -T linux"

@edwardbeckett Yep, TERM=xterm is one of the most supported across the platforms we use (linux/osx/windows). ansi and vt100 are not available in msys. Type toe to get the list of supported terminal types in msys... the problem is not with clear.

ansi and vt100 are not available in msys.
I'm using ConEmu terminal emulator, msys2 bash, msys2 git and I am showing support for both ansi and vt100... Though it's most likely from ConEmu - It supports vt100 and ansi

ansi_vt100

Was this page helpful?
0 / 5 - 0 ratings

Related issues

weabot picture weabot  ยท  3Comments

juicygoose picture juicygoose  ยท  3Comments

dbkaplun picture dbkaplun  ยท  3Comments

laur1s picture laur1s  ยท  3Comments

leo picture leo  ยท  3Comments