Skip to content
This repository

cls command does not work on windows #181

Closed
jstenar opened this Issue October 22, 2010 · 20 comments

5 participants

Jörgen Stenarson Fernando Perez Min RK Phillip M. Feldman Thomas Kluyver
Jörgen Stenarson
Collaborator

Hi,

the cls command does not work on windows with the pull from the master branch.
Instead of clearing the screen I only get a garbage character output (see below, * is placeholder for garbage character that was not possible to paste into the issue)

/Jörgen

C:\python\external>ipython
Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)]
Type "copyright", "credits" or "license" for more information.

IPython 0.11.alpha1.git -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.

In [1]: cls
*

Fernando Perez
Owner

Ouch, sorry.

Can you test what

!cls

and

os.system('cls')

do? That will let us know how to go about fixing this one.

Jörgen Stenarson
Collaborator

!cls shows the same problem, os.system("cls") works as expected.

/Jörgen

Fernando Perez
Owner

OK, thanks for testing. That tells me what direction to go in. Sorry about that, for now perhaps just make a personal magic that does the os.system() call (in fact, that may need to be the long-term solution).

Fernando Perez
Owner

I should also mention that if you're using the new Qt console, there Ctrl-L does a screen clear, so it could come in handy as well. But we'll need to fix the actual bug, of course :)

Phillip M. Feldman

Fernando,

Why was this issue closed without being resolved?

Phillip

Fernando Perez fperez reopened this September 20, 2011
Fernando Perez
Owner

No idea, it looks like it was accidentally closed. Probably an errant mouse click, thanks for bringing it to our attention again!

Thomas Kluyver
Collaborator

I think this is because on Windows, the !command syntax defaults to ip.system_piped, which won't work for commands manipulating the terminal (as I assume cls does). @minrk, I remember you worked on this - do you remember why we default to system_piped for Windows terminals, when we use system_raw in Unix terminals?

Min RK
Owner

I don't remember. The original discussion is in #297. Even from that, it's not clear why os.system isn't used on Windows.

Jörgen Stenarson
Collaborator
Min RK
Owner

Do you want to do a PR that does os.system for magic_cls on Windows?

Or, if we can't find a reason to use system_piped in the Terminal on Windows, we can just make Windows always use os.system. My guess is it has to do with piping through pyreadline in order to get ANSI colors to work, but what subprocesses use unix color output on Windows?

Jörgen Stenarson jstenar referenced this issue from a commit in jstenar/ipython October 20, 2011
Add magic for cls on windows. Fix for #181. fa95145
Jörgen Stenarson
Collaborator
Phillip M. Feldman

I put the following into my ipy_user_conf.py file, but it didn't resolve the problem:

import os

def magic_cls(ip, x):
os.system("cls")

ip.define_magic("cls", magic_cls)

I still get the symbol that stands for "female". Perhaps some radical feminist is at work here?

Thomas Kluyver
Collaborator

If you're using IPython 0.11 or trunk, ipy_user_conf.py is no longer used. You need to look for profile_default/ipython_config.py (and the format is different as well)

Jörgen Stenarson
Collaborator
Phillip M. Feldman
Thomas Kluyver
Collaborator
Thomas Kluyver
Collaborator

I've opened #914 for an easier way to do this sort of config.

Thomas Kluyver takluyver referenced this issue from a commit October 20, 2011
Add magic for cls on windows. Fix for #181. 243604a
Min RK minrk closed this October 21, 2011
Phillip M. Feldman
Thomas Kluyver
Collaborator
Fernando Perez
Owner
Min RK minrk referenced this issue from a commit in minrk/ipython November 08, 2011
Min RK use system_raw in terminal, even on Windows
`system_raw` uses `os.system` instead of `utils.process.system`, and makes
more sense in a Terminal session.

There was discussion that it should be otherwise on Windows, but I can't
find any actual evidence for why this would be the case, and there are very
clear disadvantages to not using `os.system` (see #978 and #181).

closes gh-978
a7b4809
Brian E. Granger ellisonbg referenced this issue from a commit January 10, 2012
Commit has since been removed from the repository and is no longer available.
Brian E. Granger ellisonbg referenced this issue from a commit January 10, 2012
Commit has since been removed from the repository and is no longer available.
Damián Avila damianavila referenced this issue from a commit July 30, 2013
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.