1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-11-03 08:32:03 +00:00

Compare commits

..

3 Commits
1.33 ... 1.34

Author SHA1 Message Date
nvbn
72ac9650f9 Bump to 1.34 2015-05-03 13:25:01 +02:00
nvbn
93c90d5758 #157 Don't fail if can't get brew commands 2015-05-03 13:24:33 +02:00
nvbn
3ce8c1187c Make thefuck-alias depends on current shell 2015-05-03 13:04:33 +02:00
4 changed files with 27 additions and 17 deletions

View File

@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
VERSION = '1.33'
VERSION = '1.34'
setup(name='thefuck',

View File

@@ -120,7 +120,7 @@ def run_rule(rule, command, history, settings):
def alias():
print("\nalias fuck='eval $(thefuck $(fc -ln -1))'\n")
print(shells.app_alias())
def main():

View File

@@ -2,7 +2,7 @@ import difflib
import os
import re
import subprocess
import thefuck.logs
BREW_CMD_PATH = '/Library/Homebrew/cmd'
TAP_PATH = '/Library/Taps'
@@ -10,7 +10,7 @@ TAP_CMD_PATH = '/%s/%s/cmd'
def _get_brew_path_prefix():
'''To get brew path'''
"""To get brew path"""
try:
return subprocess.check_output(['brew', '--prefix']).strip()
except:
@@ -18,18 +18,18 @@ def _get_brew_path_prefix():
def _get_brew_commands(brew_path_prefix):
'''To get brew default commands on local environment'''
"""To get brew default commands on local environment"""
brew_cmd_path = brew_path_prefix + BREW_CMD_PATH
commands = (name.replace('.rb', '') for name in os.listdir(brew_cmd_path)
if name.endswith('.rb'))
commands = [name.replace('.rb', '') for name in os.listdir(brew_cmd_path)
if name.endswith('.rb')]
return commands
def _get_brew_tap_specific_commands(brew_path_prefix):
'''To get tap's specific commands
https://github.com/Homebrew/homebrew/blob/master/Library/brew.rb#L115'''
"""To get tap's specific commands
https://github.com/Homebrew/homebrew/blob/master/Library/brew.rb#L115"""
commands = []
brew_taps_path = brew_path_prefix + TAP_PATH
@@ -61,17 +61,20 @@ def _get_directory_names_only(path):
return [d for d in os.listdir(path)
if os.path.isdir(os.path.join(path, d))]
brew_commands = []
brew_path_prefix = _get_brew_path_prefix()
# Failback commands for testing (Based on Homebrew 0.9.5)
brew_commands = ['info', 'home', 'options', 'install', 'uninstall',
'search', 'list', 'update', 'upgrade', 'pin', 'unpin',
'doctor', 'create', 'edit']
if brew_path_prefix:
brew_commands += _get_brew_commands(brew_path_prefix)
brew_commands += _get_brew_tap_specific_commands(brew_path_prefix)
else:
# Failback commands for testing (Based on Homebrew 0.9.5)
brew_commands = ['info', 'home', 'options', 'install', 'uninstall',
'search', 'list', 'update', 'upgrade', 'pin', 'unpin',
'doctor', 'create', 'edit']
try:
brew_commands = _get_brew_commands(brew_path_prefix) \
+ _get_brew_tap_specific_commands(brew_path_prefix)
except OSError:
pass
def _get_similar_commands(command):

View File

@@ -31,6 +31,9 @@ class Generic(object):
"""Prepares command for running in shell."""
return command_script
def app_alias(self):
return "\nalias fuck='eval $(thefuck $(fc -ln -1))'\n"
class Bash(Generic):
def _parse_alias(self, alias):
@@ -78,3 +81,7 @@ def from_shell(command):
def to_shell(command):
return _get_shell().to_shell(command)
def app_alias():
return _get_shell().app_alias()