Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

cls command does not work on windows #181

Closed
jstenar opened this Issue · 20 comments

5 participants

Jörgen Stenarson Fernando Perez Phillip M. Feldman Thomas Kluyver Min RK
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
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
Owner

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
J�rgen Stenarson 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
Owner

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
Owner
Thomas Kluyver
Owner

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

Thomas Kluyver takluyver referenced this issue from a commit
Jörgen Stenarson Add magic for cls on windows. Fix for #181. 243604a
Min RK minrk closed this
Phillip M. Feldman
Thomas Kluyver
Owner
Fernando Perez
Owner
Min RK minrk referenced this issue from a commit in minrk/ipython
Min RK minrk 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
Commit has since been removed from the repository and is no longer available.
Brian E. Granger ellisonbg referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
Damián Avila damianavila referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
David Renshaw dwrensha referenced this issue from a commit
Andrew Kelley andrewrk limit addQueue to 1 file at a time
this will be faster on most hard drives.
Related issue #181
3621e8d
matthew von rocketstein mattvonrocketstein referenced this issue from a commit in mattvonrocketstein/ipython
Jörgen Stenarson Add magic for cls on windows. Fix for #181. 41136a7
matthew von rocketstein mattvonrocketstein referenced this issue from a commit in mattvonrocketstein/ipython
Min RK minrk 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
f8d8e69
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.