Skip to content

Commit

Permalink
nvbn#414: Install and use win_unicode_console only on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
amtrivedi91 committed Aug 30, 2016
1 parent d252f9e commit 2423337
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@

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,
Expand Down
15 changes: 11 additions & 4 deletions thefuck/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
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
Expand All @@ -13,9 +11,18 @@
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)))
Expand Down Expand Up @@ -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())

Expand Down
1 change: 1 addition & 0 deletions thefuck/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

try:
import msvcrt

def getch():
ch = msvcrt.getch()
if ch in (b'\x00', b'\xe0'): # arrow or function key prefix?
Expand Down

0 comments on commit 2423337

Please sign in to comment.