mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-21 20:38:54 +00:00
Merge pull request #434 from scorphus/433-ioencoding
#433: Set env vars right in the aliases
This commit is contained in:
commit
a19833d0c7
@ -50,8 +50,8 @@ class TestGeneric(object):
|
|||||||
assert 'alias fuck' in shell.app_alias('fuck')
|
assert 'alias fuck' in shell.app_alias('fuck')
|
||||||
assert 'alias FUCK' in shell.app_alias('FUCK')
|
assert 'alias FUCK' in shell.app_alias('FUCK')
|
||||||
assert 'thefuck' in shell.app_alias('fuck')
|
assert 'thefuck' in shell.app_alias('fuck')
|
||||||
assert 'TF_ALIAS' in shell.app_alias('fuck')
|
assert 'TF_ALIAS=fuck PYTHONIOENCODING' in shell.app_alias('fuck')
|
||||||
assert 'PYTHONIOENCODING=utf-8' in shell.app_alias('fuck')
|
assert 'PYTHONIOENCODING=utf-8 thefuck' in shell.app_alias('fuck')
|
||||||
|
|
||||||
def test_get_history(self, history_lines, shell):
|
def test_get_history(self, history_lines, shell):
|
||||||
history_lines(['ls', 'rm'])
|
history_lines(['ls', 'rm'])
|
||||||
@ -112,8 +112,8 @@ class TestBash(object):
|
|||||||
assert 'alias fuck' in shell.app_alias('fuck')
|
assert 'alias fuck' in shell.app_alias('fuck')
|
||||||
assert 'alias FUCK' in shell.app_alias('FUCK')
|
assert 'alias FUCK' in shell.app_alias('FUCK')
|
||||||
assert 'thefuck' in shell.app_alias('fuck')
|
assert 'thefuck' in shell.app_alias('fuck')
|
||||||
assert 'TF_ALIAS' in shell.app_alias('fuck')
|
assert 'TF_ALIAS=fuck PYTHONIOENCODING' in shell.app_alias('fuck')
|
||||||
assert 'PYTHONIOENCODING=utf-8' in shell.app_alias('fuck')
|
assert 'PYTHONIOENCODING=utf-8 thefuck' in shell.app_alias('fuck')
|
||||||
|
|
||||||
def test_get_history(self, history_lines, shell):
|
def test_get_history(self, history_lines, shell):
|
||||||
history_lines(['ls', 'rm'])
|
history_lines(['ls', 'rm'])
|
||||||
@ -193,8 +193,8 @@ class TestFish(object):
|
|||||||
assert 'function fuck' in shell.app_alias('fuck')
|
assert 'function fuck' in shell.app_alias('fuck')
|
||||||
assert 'function FUCK' in shell.app_alias('FUCK')
|
assert 'function FUCK' in shell.app_alias('FUCK')
|
||||||
assert 'thefuck' in shell.app_alias('fuck')
|
assert 'thefuck' in shell.app_alias('fuck')
|
||||||
assert 'TF_ALIAS' in shell.app_alias('fuck')
|
assert 'TF_ALIAS=fuck PYTHONIOENCODING' in shell.app_alias('fuck')
|
||||||
assert 'PYTHONIOENCODING=utf-8' in shell.app_alias('fuck')
|
assert 'PYTHONIOENCODING=utf-8 thefuck' in shell.app_alias('fuck')
|
||||||
|
|
||||||
def test_get_history(self, history_lines, shell):
|
def test_get_history(self, history_lines, shell):
|
||||||
history_lines(['- cmd: ls', ' when: 1432613911',
|
history_lines(['- cmd: ls', ' when: 1432613911',
|
||||||
@ -252,8 +252,8 @@ class TestZsh(object):
|
|||||||
assert 'alias fuck' in shell.app_alias('fuck')
|
assert 'alias fuck' in shell.app_alias('fuck')
|
||||||
assert 'alias FUCK' in shell.app_alias('FUCK')
|
assert 'alias FUCK' in shell.app_alias('FUCK')
|
||||||
assert 'thefuck' in shell.app_alias('fuck')
|
assert 'thefuck' in shell.app_alias('fuck')
|
||||||
assert 'TF_ALIAS' in shell.app_alias('fuck')
|
assert 'TF_ALIAS=fuck PYTHONIOENCODING' in shell.app_alias('fuck')
|
||||||
assert 'PYTHONIOENCODING=utf-8' in shell.app_alias('fuck')
|
assert 'PYTHONIOENCODING=utf-8 thefuck' in shell.app_alias('fuck')
|
||||||
|
|
||||||
def test_get_history(self, history_lines, shell):
|
def test_get_history(self, history_lines, shell):
|
||||||
history_lines([': 1432613911:0;ls', ': 1432613916:0;rm'])
|
history_lines([': 1432613911:0;ls', ': 1432613916:0;rm'])
|
||||||
|
@ -38,8 +38,8 @@ class Generic(object):
|
|||||||
return command_script
|
return command_script
|
||||||
|
|
||||||
def app_alias(self, fuck):
|
def app_alias(self, fuck):
|
||||||
return "alias {0}='TF_ALIAS={0} PYTHONIOENCODING=utf-8 " \
|
return "alias {0}='eval $(TF_ALIAS={0} PYTHONIOENCODING=utf-8 " \
|
||||||
"eval $(thefuck $(fc -ln -1))'".format(fuck)
|
"thefuck $(fc -ln -1))'".format(fuck)
|
||||||
|
|
||||||
def _get_history_file_name(self):
|
def _get_history_file_name(self):
|
||||||
return ''
|
return ''
|
||||||
@ -103,8 +103,8 @@ class Generic(object):
|
|||||||
|
|
||||||
class Bash(Generic):
|
class Bash(Generic):
|
||||||
def app_alias(self, fuck):
|
def app_alias(self, fuck):
|
||||||
return "TF_ALIAS={0} alias {0}='PYTHONIOENCODING=utf-8 " \
|
return "alias {0}='eval " \
|
||||||
"eval $(thefuck $(fc -ln -1));" \
|
"$(TF_ALIAS={0} PYTHONIOENCODING=utf-8 thefuck $(fc -ln -1));" \
|
||||||
" history -r'".format(fuck)
|
" history -r'".format(fuck)
|
||||||
|
|
||||||
def _parse_alias(self, alias):
|
def _parse_alias(self, alias):
|
||||||
@ -152,7 +152,7 @@ class Fish(Generic):
|
|||||||
' set -l exit_code $status\n'
|
' set -l exit_code $status\n'
|
||||||
' set -l fucked_up_command $history[1]\n'
|
' set -l fucked_up_command $history[1]\n'
|
||||||
' env TF_ALIAS={0} PYTHONIOENCODING=utf-8'
|
' env TF_ALIAS={0} PYTHONIOENCODING=utf-8'
|
||||||
' thefuck $fucked_up_command | read -l unfucked_command\n'
|
' thefuck $fucked_up_command | read -l unfucked_command\n'
|
||||||
' if [ "$unfucked_command" != "" ]\n'
|
' if [ "$unfucked_command" != "" ]\n'
|
||||||
' eval $unfucked_command\n'
|
' eval $unfucked_command\n'
|
||||||
' if test $exit_code -ne 0\n'
|
' if test $exit_code -ne 0\n'
|
||||||
@ -203,9 +203,8 @@ class Fish(Generic):
|
|||||||
|
|
||||||
class Zsh(Generic):
|
class Zsh(Generic):
|
||||||
def app_alias(self, fuck):
|
def app_alias(self, fuck):
|
||||||
return "TF_ALIAS={0}" \
|
return "alias {0}='eval $(TF_ALIAS={0} PYTHONIOENCODING=utf-8" \
|
||||||
" alias {0}='PYTHONIOENCODING=utf-8 " \
|
" thefuck $(fc -ln -1 | tail -n 1));" \
|
||||||
"eval $(thefuck $(fc -ln -1 | tail -n 1));" \
|
|
||||||
" fc -R'".format(fuck)
|
" fc -R'".format(fuck)
|
||||||
|
|
||||||
def _parse_alias(self, alias):
|
def _parse_alias(self, alias):
|
||||||
|
@ -281,4 +281,6 @@ class CorrectedCommand(object):
|
|||||||
if settings.alter_history:
|
if settings.alter_history:
|
||||||
shells.put_to_history(self.script)
|
shells.put_to_history(self.script)
|
||||||
# This depends on correct setting of PYTHONIOENCODING by the alias:
|
# This depends on correct setting of PYTHONIOENCODING by the alias:
|
||||||
|
logs.debug(u'PYTHONIOENCODING: {}'.format(
|
||||||
|
os.environ.get('PYTHONIOENCODING', '>-not-set-<')))
|
||||||
print(self.script)
|
print(self.script)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user