1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-01-31 10:11:14 +00:00

#414: Install and use win_unicode_console only on windows

This commit is contained in:
nvbn 2015-12-01 20:15:27 +08:00
parent f9aa0e7c6b
commit 0560f4ba8e
3 changed files with 15 additions and 6 deletions

View File

@ -22,8 +22,9 @@ elif (3, 0) < version < (3, 3):
VERSION = '3.2'
install_requires = ['psutil', 'colorama', 'six', 'decorator', 'win_unicode_console']
extras_require = {':python_version<"3.4"': ['pathlib']}
install_requires = ['psutil', 'colorama', 'six', 'decorator']
extras_require = {':python_version<"3.4"': ['pathlib'],
":sys_platform=='win32'": ['win_unicode_console']}
setup(name='thefuck',
version=VERSION,

View File

@ -2,8 +2,6 @@ from argparse import ArgumentParser
from warnings import warn
from pprint import pformat
import sys
import win_unicode_console
win_unicode_console.enable() #https://github.com/tartley/colorama/issues/32
import colorama
from . import logs, types, shells
from .conf import settings
@ -13,9 +11,18 @@ from .utils import get_installation_info
from .ui import select_command
def init_colorama():
if sys.platform == 'win32':
# https://github.com/tartley/colorama/issues/32
import win_unicode_console
win_unicode_console.enable()
colorama.init()
def fix_command():
"""Fixes previous command. Used when `thefuck` called without arguments."""
colorama.init()
init_colorama()
settings.init()
with logs.debug_time('Total'):
logs.debug(u'Run with settings: {}'.format(pformat(settings)))
@ -53,7 +60,7 @@ def how_to_configure_alias():
It'll be only visible when user type fuck and when alias isn't configured.
"""
colorama.init()
init_colorama()
settings.init()
logs.how_to_configure_alias(shells.how_to_configure())

View File

@ -7,6 +7,7 @@ from . import logs
try:
import msvcrt
def getch():
ch = msvcrt.getch()
if ch in (b'\x00', b'\xe0'): # arrow or function key prefix?