Skip to content

Commit

Permalink
Merge pull request #384 from scorphus/fish-func
Browse files Browse the repository at this point in the history
Improve the Fish Shell function making it faster
  • Loading branch information
nvbn committed Oct 18, 2015
2 parents 540ff7e + f5e8fe9 commit f374142
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions thefuck/shells.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,20 @@ def _get_overridden_aliases(self):
return ['cd', 'grep', 'ls', 'man', 'open']

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

@memoize
def get_aliases(self):
Expand Down

0 comments on commit f374142

Please sign in to comment.