npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

typex

v0.4.3

Published

Unix CLI that provides salient information about installed commands, programs, and filesystem items, combining elements from standard Unix utilities type, which, and file.

Downloads

25

Readme

npm version license

Contents

typex — introduction

typex is an enhanced version of the type Unix shell builtin that incorporates features from the which and file utilities:
By default, it provides information about the current shell.
Given a name, it indicates how the current shell would interpret that name as a command, and provides information about each command form found.
Given a filesystem path, it provides information such as file type and canonical path.

typex extends type as follows:

  • All defined forms of a given command name are (always) reported, which includes shell keywords, aliases, shell functions, builtins, and executables.
  • Defined forms are listed in descending order of precedence - the first form listed is the effective one.
  • If an executable is a symlink, the entire chain of symlinks up to and including the ultimate target is printed, using absolute paths.
  • The type of executable is printed, including the specific shell/interpreter used to run executable scripts.
  • Version information, if available, is printed for executables.
  • Optionally, you can get information about any filesystem object, including its canoncial path and symlink chain, if applicable.

Note: typex is designed for interactive use, to provide humans with concise, salient information about a command or filesystem object. As such, its output is geared toward readability by humans, and should not be relied on for programmatic parsing.

See the examples below, concise usage information further below, or read the manual.

For supported platforms and shells, see the Installation chapter.

Examples

# Print information about the current shell.
$ typex
BINARY:     /bin/bash  [GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin14)]

# Print information about command forms named 'printf' in order of precedence.
$ typex printf
BUILTIN:    printf
BINARY:     /usr/bin/printf  [printf (GNU coreutils) 8.21]

# Print information about binary 'nawk'; note the chain of symlinks,
# and its use of *absolute* paths, as well as the version information.
$ typex nawk
BINARY:     /usr/bin/nawk@ -> /etc/alternatives/nawk@ -> /usr/bin/gawk  [GNU Awk 4.0.1]

# Print information about executable script 'npm';
# note the interpreter information ('POSIX shell script').
$ typex npm
SCRIPT:     /usr/bin/npm@ -> /usr/lib/node_modules/npm/bin/npm-cli.js  (POSIX shell script)  [2.11.3]

# Print information about an alias:
$ alias lsx='ls -FAhl'
$ typex lsx
ALIAS:      lsx='ls -FAhl'
  BINARY:     /bin/ls  [ls (GNU coreutils) 8.21]

# Print the canonical path of a directory:
$ typex /etc/apache2/
DIRECTORY:  /etc/apache2 -> /private/etc/apache2

# Print extended information about special file /dev/null
$ typex -v /dev/null
FILE:       /dev/null  (character special )
	crw-rw-rw- 1 root root 1, 3 Feb  1 19:43

Installation

Supported platforms

  • When installing from the npm registry: Linux and OS X
  • When installing manually: any Unix-like platform with Bash that uses either BSD or GNU utilities.

Supported shells

For this utility to detect the current shell's aliases, keywords, functions, and builtins, it must be sourced, which is supported in the following shells:

  • Bash, Ksh, and Zsh

typex can still be useful in unsupported shells when invoked standalone (in which case it runs in bash), albeit in limited form:

  • only executable files and filesystem objects will be detected - no other command forms.
  • a warning to that effect is printed; you can suppress it with -p

Simply put, non-sourced use of typex amounts to an enhanced version of the which utility.

Installation from the npm registry

Note: Even if you don't use Node.js, its package manager, npm, works across platforms and is easy to install; try curl -L http://git.io/n-install | bash

With Node.js or io.js installed, install the package as follows:

[sudo] npm install typex -g

Note:

  • Whether you need sudo depends on how you installed Node.js / io.js and whether you've changed permissions later; if you get an EACCES error, try again with sudo.
  • The -g ensures global installation and is needed to put typex in your system's $PATH.

IMPORTANT: After installation, run typex -i to add sourcing of typex to the per-user initialization file of all supported shells that are present (e.g., ~/.bashrc). To remove these sourcing commands later, run typex -u.

Manual installation

  • Download this bash script as typex.
  • Make it executable with chmod +x typex.
  • Move it or symlink it to a folder in your $PATH, such as /usr/local/bin (OS X) or /usr/bin (Linux).

IMPORTANT: After installation, run typex -i to add sourcing of typex to the per-user initialization file of all supported shells that are present (e.g., ~/.bashrc). To remove these sourcing commands later, run typex -u.

Usage

Find concise usage information below; for complete documentation, read the manual online, or, once installed, run man typex (typex --man if installed manually).

$ typex --help


Reports salient information about available commands, programs, and  
filesystem items, such as command or file type, (ultimate) location,  
and version.

    typex [-p] [-V] [-v] [<nameOrPath>...]

    -p     look for files only (ignore shell aliases, keywords, functions,  
           builtins)
    -V     skip attempt to obtain executable version information
    -v     verbose mode: report additional information

Install / uninstall sourcing via shell-initialization files (required  
to detect aliases, functions, shell builtins - supported in  
Bash, Ksh, Zsh):

    typex -i
    typex -u

License

Copyright (c) 2015-2020 Michael Klement [email protected] (http://same2u.net), released under the MIT license.

Acknowledgements

This project gratefully depends on the following open-source components, according to the terms of their respective licenses.

npm dependencies below have optional suffixes denoting the type of dependency; the absence of a suffix denotes a required run-time dependency: (D) denotes a development-time-only dependency, (O) an optional dependency, and (P) a peer dependency.

npm dependencies

Changelog

Versioning complies with semantic versioning (semver).

  • v0.4.3 (2020-10-13):

    • [fix] npm v6.14.8 inexplicably complains about the "install" command in package.json (which simply printfs an informational message), so it is diabled for now.
  • v0.4.2 (2020-10-13):

    • [fix] Syntax error fixed that was masked by an accidental non-breaking space Unicode char.
  • v0.4.1 (2015-09-21):

    • [fix] typex / now works correctly.
  • v0.4.0 (2015-09-21):

    • [potentially breaking change] typex now accepts options after operands as well (except after --), and now also accepts long option names.
    • [doc] typex now has a man page (if manually installed, use typex --man); typex -h now just prints concise usage information.
    • [doc] Read-me improved.
    • [fix] Various fixes and stability improvements.
    • [dev] Installation of sourcing (with -i) no longer uses ed so as to work on a wider range of platforms, notably Fedora.
    • [dev] Tests improved, additional tests added.
  • v0.3.3 (2015-09-15):

    • [dev] Makefile improvements; various other behind-the-scenes tweaks.
  • v0.3.2 (2015-09-03):

    • [fix] Broken (dangling) symlinks are now properly detected and reported.
  • v0.3.1 (2015-06-26):

    • [dev] Makefile updated; to-do file added; typo in source-code comment fixed.
    • [doc] Minor read-me revision.
  • v0.3.0 (2015-06-10):

    • [behavior change, enhancement] When reporting on an alias, information about the underlying command is now output with indentation, so as to make it clear that the information is subordinate to the alias information.
    • [fix] Reporting on an alias' underlying command no longer causes additional command forms of the same name to be ignored.
    • [fix] Obtaining a file's last-modified timestamp no longer breaks with filenames with embedded spaces.
    • [doc] Read-me improvements; version badge switched to shields.io; license badge added.
  • v0.2.1 (2015-05-30):

  • v0.2.0 (2015-05-24):

    • [enhancement] Now by default prints information about the current shell (if no names are given).
    • [enhancement] Specifying . now also prints the current directory's canonical path.
    • [enhancement] Given a filesystem path, now also displays its canonical path with all symlinks resolved, if different.
    • [enhancement] A warning is now issued if a bareword can't be found as a command, but a file or dir. of the same name exists in the current dir.
    • [enhancement] For aliases, their definitions are now printed recursively, if applicable, and, if the ultimate definition's first token is a command, its information is printed as well.
    • [fix] typex perl now correctly reports Perl's version.
    • [fix] Paths with embedded space are now handled correctly.
  • v0.1.7 (2015-03-04):

    • Fix: Variables $u and $i that happen to be defined in the current shell no longer interfere with the sourced function.
  • v0.1.6 (2015-02-11):

    • Temp. fix: typex -i now properly reports failure on platforms that don't have the actual ed line editor, such as Debian.
  • v0.1.5 (2015-02-11):

    • Fix: --version no longer mistakenly exits the current shell when typex is invoked as a sourced function.
    • Dev: bash-presence test improved.
    • Dev: Makefile improvements.
  • v0.1.4 (2015-02-11):

    • Fix: Filenames that start with '-' are now handled correctly.
    • Dev: bash-presence test added.
    • Dev: Makefile improvements.
  • v0.1.3 (2015-02-09):

    • Doc: read-me and package description improved.
  • v0.1.2 (2015-02-07):

    • Fix: sourcing no longer auto-installed/-removed on package installation - removed due to permission headaches; users must now run typex -i manually after installation.
  • v0.1.1 (2015-02-07):

    • Fix: --version reported incorrect version number.
    • Temp. fix: installation of sourcing with -i doesn't report error in case of failure so as not to prevent installation of the npm package altogether.
  • v0.1.0 (2015-02-07):

    • Initial release.