Some functions I have installed in my ~/.bash_profile
to make life easier. Source code
Clone a repo into your projects folder and cd
into it.
function clone {
cd ~/projects;
git clone $1;
reponame=$(basename $1);
cd ${reponame/.git/};
}
$ clone [email protected]:jezen/is-thirteen.git
Cloning into 'is-thirteen'...
remote: Counting objects: 934, done.
remote: Total 934 (delta 0), reused 0 (delta 0), pack-reused 934
Receiving objects: 100% (934/934), 151.95 KiB | 0 bytes/s, done.
Resolving deltas: 100% (570/570), done.
shaundonnelly at shaudonn01m in ~/projects/is-thirteen on master
# We've cloned the repo and we're now inside it.
Open the current repository in your default browser.
function show-repo {
git remote -v | grep origin | awk ' { print $2 }' | uniq | tr ':' '/' | sed "s|git\@|http://|"
}.
function repo {
show-repo | xargs open
}
shaundonnelly at shaudonn01m in ~/projects/is-thirteen on master
$ repo
# (https://github.com/jezen/is-thirteen opens in my browser)
Allows you to run locally installed npm packages without needing them to be installed globally.
function npm-do {
(PATH=$(npm bin):$PATH; eval $@;)
}
# Show that webpack is installed as a dependency.
$ npm ls --depth=0
[email protected] /Users/shaundonnelly/Desktop/test
└── [email protected]
# Try to run webpack without installing it globally first, doesn't work.
$ webpack
-bash: webpack: command not found
# Run webpack via `npm-do`, it now works as it's installed locally in the current project.
$ npm-do webpack
No configuration file found and no output filename configured via CLI option.
A configuration file could be named 'webpack.config.js' in the current directory.
Use --help to display the CLI options.