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

@jstenar
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
*

@fperez
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.

@jstenar
Collaborator

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

/Jörgen

@fperez
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).

@fperez
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 :)

@pmfeldman

Fernando,

Why was this issue closed without being resolved?

Phillip

@fperez fperez reopened this
@fperez
Owner

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

@takluyver
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?

@minrk
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.

@jstenar
Collaborator
@minrk
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?

@jstenar jstenar referenced this issue from a commit in jstenar/ipython
J�rgen Stenarson Add magic for cls on windows. Fix for #181. fa95145
@jstenar
Collaborator
@pmfeldman

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?

@takluyver
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)

@jstenar
Collaborator
@pmfeldman
@takluyver
Owner
@takluyver
Owner

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

@takluyver takluyver referenced this issue from a commit
Jörgen Stenarson Add magic for cls on windows. Fix for #181. 243604a
@minrk minrk closed this
@pmfeldman
@takluyver
Owner
@fperez
Owner
@minrk minrk referenced this issue from a commit in minrk/ipython
@minrk 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
@ellisonbg ellisonbg referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@ellisonbg ellisonbg referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@damianavila damianavila referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@dwrensha dwrensha referenced this issue from a commit
@andrewrk andrewrk limit addQueue to 1 file at a time
this will be faster on most hard drives.
Related issue #181
3621e8d
@mattvonrocketstein mattvonrocketstein referenced this issue from a commit in mattvonrocketstein/ipython
Jörgen Stenarson Add magic for cls on windows. Fix for #181. 41136a7
@mattvonrocketstein mattvonrocketstein referenced this issue from a commit in mattvonrocketstein/ipython
@minrk 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.