Skip to content

Instantly share code, notes, and snippets.

@msikma
Last active April 18, 2019 23:15
Show Gist options
  • Save msikma/addce5c8cd218c863e1e4b297aa6ae7b to your computer and use it in GitHub Desktop.
Save msikma/addce5c8cd218c863e1e4b297aa6ae7b to your computer and use it in GitHub Desktop.
function check_node_project \
--description 'Display project info if we changed to a Node project directory' \
--on-variable dirprev
# Don't display project info if:
status --is-command-substitution; # this is command substitution \
or not test -f ./package.json; # there's no package.json \
or [ (count $dirprev) -lt 2 ]; # we've just opened a new Terminal session \
# Uncomment this if you only want the project info to be shown when coming from a lower directory.
# or [ (count (string split $PWD $dirprev[-1])) -eq 2 ]; # we came from a lower directory in the hierarchy \
and return
# Displays project name, version, and a list of bin files, npm scripts and docs.
project.js
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment