1
0
mirror of https://github.com/nvbn/thefuck.git synced 2024-10-06 02:41:10 +01:00

Improve the Fish Shell function making it faster

It works now with no temp file involved, which makes it a lot faster.
Also, `history --merge`, although only supported on Fish Shell 2.2+,
merges the corrected entry back into history. Neat!

Ref #89
This commit is contained in:
Pablo Santiago Blum de Aguiar 2015-10-15 23:57:13 -03:00
parent 3da26192cb
commit f5e8fe954e

View File

@ -126,19 +126,20 @@ class Fish(Generic):
return ['cd', 'grep', 'ls', 'man', 'open'] return ['cd', 'grep', 'ls', 'man', 'open']
def app_alias(self, fuck): def app_alias(self, fuck):
return ("set TF_ALIAS {0}\n" return ('function {0} -d "Correct your previous console command"\n'
"function {0} -d 'Correct your previous console command'\n" ' set -l exit_code $status\n'
" set -l exit_code $status\n" ' set -x TF_ALIAS {0}\n'
" set -l eval_script" ' set -l fucked_up_command $history[1]\n'
" (mktemp 2>/dev/null ; or mktemp -t 'thefuck')\n" ' thefuck $fucked_up_command | read -l unfucked_command\n'
" set -l fucked_up_command $history[1]\n" ' if [ "$unfucked_command" != "" ]\n'
" thefuck $fucked_up_command > $eval_script\n" ' eval $unfucked_command\n'
" . $eval_script\n" ' if test $exit_code -ne 0\n'
" /bin/rm $eval_script\n" ' history --delete $fucked_up_command\n'
" if test $exit_code -ne 0\n" ' history --merge ^ /dev/null\n'
" history --delete $fucked_up_command\n" ' return 0\n'
" end\n" ' end\n'
"end").format(fuck) ' end\n'
'end').format(fuck)
@memoize @memoize
def get_aliases(self): def get_aliases(self):