1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-13 22:28:33 +00:00

default fuckups

This commit is contained in:
Jared Henry Oviatt 2015-05-06 21:27:32 -07:00
parent fd665be8a9
commit c2edf5214a
3 changed files with 18 additions and 8 deletions

View File

@ -30,6 +30,8 @@ DEFAULT_SETTINGS = {'rules': DEFAULT_RULES,
'require_confirmation': False,
'no_colors': False}
DEFAULT_FUCKUPS = {'cd..':'cd ..'}
ENV_TO_ATTR = {'THEFUCK_RULES': 'rules',
'THEFUCK_WAIT_COMMAND': 'wait_command',
'THEFUCK_REQUIRE_CONFIRMATION': 'require_confirmation',
@ -115,3 +117,13 @@ def initialize_settings_file(user_dir):
settings_file.write(SETTINGS_HEADER)
for setting in DEFAULT_SETTINGS.items():
settings_file.write(u'# {} = {}\n'.format(*setting))
def initialize_fuckups_file(user_dir):
fuckups_path = user_dir.joinpath('.my_fuckups')
if not fuckups_path.is_file():
with fuckups_path.open(mode='w') as fuckups_file:
for key, fix in DEFAULT_FUCKUPS.iteritems():
fuckups_file.write(key + '\n')
fuckups_file.write(fix + '\n')
return

View File

@ -1,7 +1,7 @@
# handle reading and writing local list of fuckups
# fuckups are stored in ~/.thefuck/my_fuckups
# fuckups are stored locally in ~/.thefuck/my_fuckups
# file format:
# fucked up command
@ -12,11 +12,9 @@
# rule is in rules/myfuckups.py
# TODO default fuckups (could replace some existing rules with these, mostly typo rules) in ~/.thefuck/my_fuckups
def get_fuckups(): # returns a dictionary of your fuckups from ~/.thefuck/my_fuckups
def get_fuckups(): # returns a dictionary of your fuckups from ~/.thefuck/.my_fuckups
FILENAME = '~/.thefuck/my_fuckups'
FILENAME = '~/.thefuck/.my_fuckups'
FILE = open(FILENAME, 'r')
IS_FUCKUP = True
@ -40,7 +38,7 @@ def add_fuckup(fucked, fixed):
print ('Adding fucked: ' + fucked + ' as fixed: ' + fixed)
FILENAME = '~/.thefuck/my_fuckups'
FILENAME = '~/.thefuck/.my_fuckups'
FILE = open(FILENAME, 'w')
FILE.write(fucked + '\n')
@ -54,7 +52,7 @@ def remove_fuckup(fuckup):
print ('Removing fucked: ' + fucked + ' as fixed: ' + fixed)
FILENAME = '~/.thefuck/my_fuckups'
FILENAME = '~/.thefuck/.my_fuckups'
FILE = open(FILENAME, 'r')
fuckup_cmd = ''

View File

@ -1,5 +1,5 @@
import custom_fuckups
import thefuck.custom_fuckups
fuckups = custom_fuckups.get_fuckups()