Repository navigation
Expand file tree
/
Copy pathfunctions
More file actions
81 lines (61 loc) · 2.65 KB
/
Copy pathfunctions
File metadata and controls
81 lines (61 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# kill port faster from command line (free up port easily)
# usage: Running: `killport 3000` will free up port 3000
function killport(){ lsof -nti:$1 | xargs kill -9 };
eslint-boilerplate(){
git clone https://github.com/kingluddite/eslint-boilerplate.git . && npm i
}
css-boilerplate() {
# Clone just the repository's .git folder (excluding files as they are already in
# `existing-dir`) into an empty temporary directory
git clone --no-checkout https://github.com/kingluddite/my-css-boilerplate.git existing-dir/existing-dir.tmp;
# note: this would be simple and we could stop here if we cloned into an empty folder
# all the following steps are necessary if we clone into a folder with existing files
# we can't (by default) clone into a file with existing files
# most of the time we'll want to add our boilerplate to an existing repo
# so we need to add all of the following steps to clone a git repo into a folder with existing files
# Move the .git folder to the directory with the files.
# This makes `existing-dir` a git repo.
mv existing-dir/existing-dir.tmp/.git existing-dir/;
# Delete the temporary directory and change into existing-dir
rmdir existing-dir/existing-dir.tmp;
cd existing-dir
# git thinks all files are deleted, this reverts the state of the repo to HEAD.
# WARNING: any local changes to the files will be lost.
git reset --hard HEAD;
# blow up the .git folder
rm -rf .git;
# move everything all normal files and folders into the parent folder (root of app you are cloning into)
mv * ../;
# And you also want to move all hidden files (if you don't do this step, no hidden files will be moved)
mv .* ../;
# change into the parent directory (root of app you are cloning into)
cd ..
# remove the folder you temporarily created to make this possible
rm -rf existing-dir;
# install all dependencies
npm i;
}
# css-boilerplate(){
# git clone https://github.com/kingluddite/my-css-boilerplate.git . && npm i
# }
function cdl { cd $1; ls;}
# Install `tree` first — brew install tree
function _t() {
# Defaults to 3 levels deep, do more with `t 5` or `t 1`
# pass additional args after
local levels=${1:-3}; shift
tree -I '.git|node_modules|bower_components|.DS_Store' --dirsfirst -L $levels -aC $@
}
timezsh() {
shell=${1-$SHELL}
for i in $(seq 1 10); do /usr/bin/time $shell -i -c exit; done
}
# Generate .gitignore
# `$ gi node,macos >> .gitignore`
function gi() { curl -sLw "\n" https://www.gitignore.io/api/\$@ ;}
#########
# graveyard
#########
# gulp-boilerplate(){
# git clone https://github.com/kingluddite/webpack-gulp-boilerplate.git $1 && cd $1 && yarn && npm run dev
# }