-
Notifications
You must be signed in to change notification settings - Fork 0
/
.functions
90 lines (73 loc) · 2.43 KB
/
.functions
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
82
83
84
85
86
87
88
89
90
## Open man page as PDF
pman () { man -t "${1}" | open -f -a "Preview"; }
## Show the location of a linked program
ref() { readlink $(which "${1}"); }
#http://www.jayway.com/2014/01/15/how-to-switch-jdk-version-on-mac-os-x-maverick/
function setjdk() {
if [ $# -ne 0 ]; then
removeFromPath '/System/Library/Frameworks/JavaVM.framework/Home/bin'
if [ -n "${JAVA_HOME+x}" ]; then
removeFromPath $JAVA_HOME
fi
export JAVA_HOME=`/usr/libexec/java_home -v $@`
export PATH=$JAVA_HOME/bin:$PATH
fi
}
function removeFromPath() {
export PATH=$(echo $PATH | sed -E -e "s;:$1;;" -e "s;$1:?;;")
}
setjdk 1.8
#Some Info when running Maven
mvnrun () {
echo mvn $@
eval mvn $@
echo mvn $@
}
## Output MANIFEST for the given jar
manifest() { unzip -q -c "${1}" META-INF/MANIFEST.MF; }
## Output LINCENSE file for the given jar
license() { unzip -q -c "${1}" META-INF/LICENSE.txt; }
## auto detect git ignore
## requires bash 4!
## Note that bash 4 has to be defined as login shell. On Mac OS this has to be
## done via System preferences > Users > right click our profil picture > extended options
gitignore() {
declare -A files
files["pom.xml"]=maven
files["build.gradle"]=gradle
files["build.sbt"]=sbt
files["Cargo.toml"]=rust
for file in "${!files[@]}"
do
if [[ -f $file ]]
then
echo "Adding $file files to .gitignore."
gibo ${files[$file]} >> .gitignore
fi
done
}
# Create a README.md file for the current directory
readme() {
project_name=$(basename $PWD)
cat > README.md << EOF
# $project_name
Welcome to $project_name!
## Contribution policy
Contributions via GitHub pull requests are gladly accepted from their original author. Along with any pull requests, please state that the contribution is your original work and that you license the work to the project under the project's open source license. Whether or not you state this explicitly, by submitting any copyrighted material via pull request, email, or other means you agree to license the material under the project's open source license and warrant that you have the legal authority to do so.
## License
This code is open source software licensed under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0.html).
EOF
}
## Push current git project to github
githubinit() {
hub create $(basename $PWD)
git push -u origin master
}
## Initialize a new project
projectinit () {
alv2
gitignore
readme
git this
githubinit
}