-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathhttp-1
47 lines (41 loc) · 1.53 KB
/
http-1
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
#!/usr/bin/env zsh
# This is a simple example of a wenv that starts an environment for a toy web
# development environment. The WENV_DIR is just set to the base directory of my
# toy website. The diretory tree for this project looks like:
#
# $ tree
# .
# ├── css
# │ └── styles.css
# ├── index.html
# └── js
# └── main.js
#
# Now look at the startup_wenv(). This starts by using wenv_tmux_split() to
# open a new window, named 'http', and run the command 'python -m http.server'
# (to run a simple HTTP server in the base directory of the wenv). After the
# first command runs, we'll be in the second tmux window. To get back to the
# first, we use the `tmux select-window` command. Then we use edit() to open
# the Javascript file main.js, which works because 'js' maps to 'main.js' in
# wenv_files. We pass the -r flag to edit() to rename the current tmux window
# to 'js'. The result of all of this is: two tmux windows, the first named 'js'
# with main.js opened in your editor, and the second named 'http' that contains
# a running python HTTP server.
wenv_dir="$HOME/scratch/webdev-practice"
wenv_deps=()
wenv_extensions=('c' 'edit')
startup_wenv() {
wenv_tmux_split -n http window 'python -m http.server'
tmux select-window -t 1
edit -r js
}
shutdown_wenv() {}
bootstrap_wenv() {}
((only_load_wenv_vars == 1)) && return 0
declare -Ag wenv_dirs
wenv_dirs[js]='js'
wenv_dirs[css]='css'
declare -Ag wenv_files
wenv_files[html]='index.html'
wenv_files[js]="js/main.js"
wenv_files[css]="css/styles.css"