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 / 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:
                _, shell = shellingham.detect_shell()
            except shellingham.ShellDetectionFailure:
                shell = os.environ.get('COMSPEC', 'cmd.exe')
            shell = 'sh'
    return shell
github dephell / dephell / dephell / View on Github external
def _shell_info(self) -> Tuple[str, Path]:
        # detect by shellingham
            name, path = detect_shell()
        except (ShellDetectionFailure, RuntimeError):
            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 / View on Github external
def get_auto_shell():
    """Returns the current shell"""
    return shellingham.detect_shell()[0]
github python-poetry / poetry / poetry / utils / View on Github external
def get(cls):  # type: () -> Shell
        Retrieve the current shell.
        if cls._shell is not None:
            return cls._shell

            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