1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-14 14:48:49 +00:00

Add shell_logger socket integration

This commit is contained in:
Sameet Sapra 2018-02-25 03:10:30 -06:00
parent 284d49da8d
commit 38310cb5fe
5 changed files with 39 additions and 3 deletions

View File

@ -134,6 +134,13 @@ eval $(thefuck --alias)
eval $(thefuck --alias FUCK)
```
If you want to enable , add place these commands in your `.bash_profile`, `.bashrc`, `.zshrc` or other startup script:
```bash
export SHELL_PATH=$(PWD)
eval $(thefuck --enable-experimental-shell-history)
```
[Or in your shell config (Bash, Zsh, Fish, Powershell, tcsh).](https://github.com/nvbn/thefuck/wiki/Shell-aliases)
Changes will be available only in a new shell session.

View File

@ -33,6 +33,10 @@ class Parser(object):
'--enable-experimental-instant-mode',
action='store_true',
help='enable experimental instant mode, use on your own risk')
self._parser.add_argument(
'--enable-experimental-shell-history',
action='store_true',
help='enable experimental shell history')
self._parser.add_argument(
'-h', '--help',
action='store_true',

View File

@ -42,7 +42,8 @@ DEFAULT_SETTINGS = {'rules': DEFAULT_RULES,
'./gradlew', 'vagrant'],
'repeat': False,
'instant_mode': False,
'env': {'LC_ALL': 'C', 'LANG': 'C', 'GIT_TRACE': '1'}}
'env': {'LC_ALL': 'C', 'LANG': 'C', 'GIT_TRACE': '1', '__SHELL_LOGGER_SOCKET': '/tmp/tf_socket',
'__SHELL_LOGGER_BINARY_PATH': '$HOME/.local/bin/shell_logger'}}
ENV_TO_ATTR = {'THEFUCK_RULES': 'rules',
'THEFUCK_EXCLUDE_RULES': 'exclude_rules',

View File

@ -1,5 +1,10 @@
import subprocess
import urllib.request
import six
from ..logs import warn
from ..conf import settings
from ..logs import warn, debug
from ..shells import shell
from ..utils import which
@ -24,3 +29,19 @@ def _get_alias(known_args):
def print_alias(known_args):
print(_get_alias(known_args))
def print_experimental_shell_history():
client_release = 'https://www.dropbox.com/s/m0jqp8i4c6woko5/client?dl=1'
filename = settings.env['__SHELL_LOGGER_BINARY_PATH']
debug('Downloading the shell_logger release and putting it in the path ... ')
urllib.request.urlretrieve(client_release, filename)
subprocess.Popen(['chmod', '+x', filename])
proc = subprocess.Popen(['./{0}'.format(filename), '-mode', 'configure'], stdout=subprocess.PIPE,
env={'__SHELL_LOGGER_BINARY_PATH': settings.env['__SHELL_LOGGER_BINARY_PATH']})
print(''.join([line.decode() for line in proc.stdout.readlines()]))
subprocess.Popen(['./{0}'.format(filename), '-mode', 'daemon'],
env={'__SHELL_LOGGER_SOCKET': settings.env['__SHELL_LOGGER_SOCKET']})

View File

@ -8,7 +8,7 @@ import sys # noqa: E402
from .. import logs # noqa: E402
from ..argument_parser import Parser # noqa: E402
from ..utils import get_installation_info # noqa: E402
from .alias import print_alias # noqa: E402
from .alias import print_alias, print_experimental_shell_history # noqa: E402
from .fix_command import fix_command # noqa: E402
@ -32,5 +32,8 @@ def main():
logs.warn('Shell logger supports only Linux and macOS')
else:
shell_logger(known_args.shell_logger)
elif known_args.enable_experimental_shell_history:
print_experimental_shell_history()
else:
parser.print_usage()