mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-16 07:38:50 +00:00
Originally this rule only worked for scripts run with relative paths (eg `./funStuff.sh`) but that's not always what we need Imagine I have a file at `/home/alice/scripts/funStuff.sh` and my cwd is `/home/alice` I could run the script with `./scripts/funStuff.sh` or '~/scripts/funStuff.sh` or `/home/alice/scripts/funStuff.sh`
15 lines
422 B
Python
15 lines
422 B
Python
import os
|
|
from thefuck.shells import shell
|
|
|
|
|
|
def match(command):
|
|
return ('permission denied' in command.output.lower()
|
|
and os.path.exists(os.path.expanduser(command.script_parts[0]))
|
|
and not os.access(os.path.expanduser(command.script_parts[0]), os.X_OK))
|
|
|
|
|
|
def get_new_command(command):
|
|
return shell.and_(
|
|
'chmod +x {}'.format(command.script_parts[0][2:]),
|
|
command.script)
|