mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-31 02:01:13 +00:00
#495: Alter history only when configured to do so
This commit is contained in:
parent
d1f55603fe
commit
96f7e53aa2
@ -74,10 +74,12 @@ class TestFish(object):
|
|||||||
assert 'TF_ALIAS=fuck PYTHONIOENCODING' in shell.app_alias('fuck')
|
assert 'TF_ALIAS=fuck PYTHONIOENCODING' in shell.app_alias('fuck')
|
||||||
assert 'PYTHONIOENCODING=utf-8 thefuck' in shell.app_alias('fuck')
|
assert 'PYTHONIOENCODING=utf-8 thefuck' in shell.app_alias('fuck')
|
||||||
|
|
||||||
def test_app_alias_history_merge(self, settings, shell):
|
def test_app_alias_alter_history(self, settings, shell):
|
||||||
settings.alter_history = True
|
settings.alter_history = True
|
||||||
|
assert 'history --delete' in shell.app_alias('FUCK')
|
||||||
assert 'history --merge' in shell.app_alias('FUCK')
|
assert 'history --merge' in shell.app_alias('FUCK')
|
||||||
settings.alter_history = False
|
settings.alter_history = False
|
||||||
|
assert 'history --delete' not in shell.app_alias('FUCK')
|
||||||
assert 'history --merge' not in shell.app_alias('FUCK')
|
assert 'history --merge' not in shell.app_alias('FUCK')
|
||||||
|
|
||||||
def test_get_history(self, history_lines, shell):
|
def test_get_history(self, history_lines, shell):
|
||||||
|
@ -20,19 +20,19 @@ class Fish(Generic):
|
|||||||
|
|
||||||
def app_alias(self, fuck):
|
def app_alias(self, fuck):
|
||||||
if settings.alter_history:
|
if settings.alter_history:
|
||||||
hist_merge = ' history --merge ^ /dev/null\n'
|
alter_history = (' history --delete $fucked_up_command\n'
|
||||||
|
' history --merge ^ /dev/null\n')
|
||||||
else:
|
else:
|
||||||
hist_merge = ''
|
alter_history = ''
|
||||||
# It is VERY important to have the variables declared WITHIN the alias
|
# It is VERY important to have the variables declared WITHIN the alias
|
||||||
return ('function {0} -d "Correct your previous console command"\n'
|
return ('function {0} -d "Correct your previous console command"\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{1}'
|
||||||
' history --delete $fucked_up_command\n{1}'
|
|
||||||
' end\n'
|
' end\n'
|
||||||
'end').format(fuck, hist_merge)
|
'end').format(fuck, alter_history)
|
||||||
|
|
||||||
@memoize
|
@memoize
|
||||||
@cache('.config/fish/config.fish', '.config/fish/functions')
|
@cache('.config/fish/config.fish', '.config/fish/functions')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user