-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.sh
52 lines (44 loc) · 1.5 KB
/
functions.sh
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
#!/usr/bin/env bash
# ----------------------------------------------------------------------------
# Helper functions
#
# Best if sourced on .bashrc or .zshrc
#
# Ex:
# [ -f "$HOME/dotfiles/functions.sh" ] && source $HOME/dotfiles/functions.sh;
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Create directory tree for a new project
#
# Ex:
# $ proj-init cool-project
# ----------------------------------------------------------------------------
proj-init() {
PROJS_DIR="$HOME/projs"
mkdir -p "$PROJS_DIR/$1"
cd "$PROJS_DIR/$1" || exit
mkdir code # source code repository
mkdir w # working files, like psd
mkdir tmp # temporary files
mkdir material # original and received files from client, do not modify here
}
# ----------------------------------------------------------------------------
# cd into project code
#
# Ex:
# $ proj cool-project
# ----------------------------------------------------------------------------
proj() {
PROJS_DIR="$HOME/projs"
cd "$PROJS_DIR/$1/code/$1" || exit
}
# ----------------------------------------------------------------------------
# Create a directory and cd into it.
#
# Ex:
# ~$ mkcd foo/bar # create a "foo/bar" directory from ~
# ~/foo/bar$ # now the current/working directory is ~/foo/bar
# ----------------------------------------------------------------------------
mkcd() {
mkdir -p "$@" && cd "$_" || exit
}