1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-01-31 18:21:10 +00:00

#N/A: Add docsting in shells

This commit is contained in:
nvbn 2016-01-24 04:39:27 +03:00
parent 20adefbe7d
commit 9b129fad08

View File

@ -1,7 +1,10 @@
from collections import defaultdict """Package with shell specific actions, each shell class should
from psutil import Process implement `from_shell`, `to_shell`, `app_alias`, `put_to_history` and
`get_aliases` methods.
"""
import os import os
import sys import sys
from psutil import Process
from ..utils import memoize from ..utils import memoize
from .. import logs from .. import logs
from .bash import Bash from .bash import Bash
@ -10,12 +13,11 @@ from .generic import Generic
from .tcsh import Tcsh from .tcsh import Tcsh
from .zsh import Zsh from .zsh import Zsh
shells = defaultdict(Generic, shells = {'bash': Bash,
bash=Bash(), 'fish': Fish,
fish=Fish(), 'zsh': Zsh,
zsh=Zsh(), 'csh': Tcsh,
csh=Tcsh(), 'tcsh': Tcsh}
tcsh=Tcsh())
@memoize @memoize
@ -24,9 +26,10 @@ def _get_shell():
shell = Process(os.getpid()).parent().name() shell = Process(os.getpid()).parent().name()
except TypeError: except TypeError:
shell = Process(os.getpid()).parent.name shell = Process(os.getpid()).parent.name
return shells[shell] return shells.get(shell, Generic)()
# Public interface of current shell:
def from_shell(command): def from_shell(command):
return _get_shell().from_shell(command) return _get_shell().from_shell(command)