How to use the shellingham.detect_shell function in shellingham

To help you get started, we’ve selected a few shellingham examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github berdario / pew / pew / pew.py View on Github external
def _detect_shell():
    shell = os.environ.get('SHELL', None)
    if not shell:
        if 'CMDER_ROOT' in os.environ:
            shell = 'Cmder'
        elif windows:
            try:
                _, shell = shellingham.detect_shell()
            except shellingham.ShellDetectionFailure:
                shell = os.environ.get('COMSPEC', 'cmd.exe')
        else:
            shell = 'sh'
    return shell
github dephell / dephell / dephell / shells.py View on Github external
def _shell_info(self) -> Tuple[str, Path]:
        # detect by shellingham
        try:
            name, path = detect_shell()
        except (ShellDetectionFailure, RuntimeError):
            pass
        else:
            return name, Path(path)

        # detect by env
        for env in ('SHELL', 'COMSPEC'):
            path = os.environ.get(env)
            if path:
                path = Path(path).resolve()
                return path.stem, path

        # try to find any known shell
        for name in sorted(self.shells):
            path = shutil.which(name)
            if path is not None:
github click-contrib / click-completion / click_completion / lib.py View on Github external
def get_auto_shell():
    """Returns the current shell"""
    return shellingham.detect_shell()[0]
github python-poetry / poetry / poetry / utils / shell.py View on Github external
def get(cls):  # type: () -> Shell
        """
        Retrieve the current shell.
        """
        if cls._shell is not None:
            return cls._shell

        try:
            name, path = detect_shell(os.getpid())
        except (RuntimeError, ShellDetectionFailure):
            raise RuntimeError("Unable to detect the current shell.")

        cls._shell = cls(name, path)

        return cls._shell

shellingham

Tool to Detect Surrounding Shell

ISC
Latest version published 1 year ago

Package Health Score

81 / 100
Full package analysis

Similar packages