mirror of https://git.envs.net/envs/burrow.git
added gophermap editing with awesome bash completion
This commit is contained in:
parent
f0f21df913
commit
487574e053
28
README.md
28
README.md
|
@ -21,35 +21,19 @@ See the [Getting Started](https://github.com/jamestomasino/burrow/wiki/Getting-S
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
burrow phlog # create new phlog post
|
burrow phlog # create new phlog post
|
||||||
burrow recipe # add or update a recipe to box
|
burrow gophermap # edit a gophermap
|
||||||
burrow topic # add or update a topic file
|
|
||||||
burrow rss # generate a RSS feed of phlog entries
|
burrow rss # generate a RSS feed of phlog entries
|
||||||
burrow create-config # generate a default config file
|
|
||||||
burrow edit-config # open your config file for editing
|
burrow edit-config # open your config file for editing
|
||||||
burrow update-git # pull latest git repo for gopher dir, if exists
|
burrow update-git # pull latest git repo for gopher dir, if exists
|
||||||
```
|
```
|
||||||
|
|
||||||
- `create-config` will auto-generate a configuration file at
|
|
||||||
`$HOME/.config/burrow/config`. It will be populated by the default parameters
|
|
||||||
listed below and provide an easy way to customize your configuration. At a
|
|
||||||
minimum you should update your `config_dir_gopher` to point to the folder on
|
|
||||||
your local computer where your gopher hole resides.
|
|
||||||
|
|
||||||
- `edit-config` will open your burrow configuration file for easy editing.
|
- `edit-config` will open your burrow configuration file for easy editing.
|
||||||
|
|
||||||
- `phlog` will prompt for the title of a new post, then open it in your default
|
- `phlog` will prompt for the title of a new post, then open it in your default
|
||||||
`$EDITOR`. By default it will provide you a template, but you can override this
|
`$EDITOR`. By default it will provide you a template, but you can override this
|
||||||
by including a `.template` file in your phlog directory.
|
by including a `.template` file in your phlog directory.
|
||||||
|
|
||||||
- `recipe` will prompt for the name of your recipe, then open it in your default
|
- `gophermap` will open a gophermap file for editing. This will
|
||||||
`$EDITOR`. By default it will provide you a template, but you can override this
|
|
||||||
by including a `.template` file in your recipe box directory.
|
|
||||||
|
|
||||||
- `topic` will prompt for the name of the topic, then open it in your default
|
|
||||||
`$EDITOR`. By default it will provide you a template, but you can override this
|
|
||||||
by including a `.template` file in your topics directory.
|
|
||||||
|
|
||||||
- `root` will open your gopher hole's root gophermap for editing. This will
|
|
||||||
remove any `type i` formatting and allow comments to be added in natural text.
|
remove any `type i` formatting and allow comments to be added in natural text.
|
||||||
You will still need to create links in the proper gophermap formatting.
|
You will still need to create links in the proper gophermap formatting.
|
||||||
|
|
||||||
|
@ -85,14 +69,6 @@ config_dir_phlog="phlog" # relative path to phlog
|
||||||
config_phlog_gophermap=true # phlogs use gophermap format by default
|
config_phlog_gophermap=true # phlogs use gophermap format by default
|
||||||
config_phlog_usedate=true # use a date-stamp on phlog posts
|
config_phlog_usedate=true # use a date-stamp on phlog posts
|
||||||
|
|
||||||
config_dir_recipebox="recipebox" # relative path to recipe box
|
|
||||||
config_recipebox_gophermap=false # recipes use plain text by default
|
|
||||||
config_recipebox_usedate=false # do not use a date-stamp on recipe filenames
|
|
||||||
|
|
||||||
config_dir_topics="topics" # relative path to topics directory
|
|
||||||
config_topics_gophermap=true # topic notes use gophermap format by default
|
|
||||||
config_topics_usedate=false # do not use a date-stamp on topic filenames
|
|
||||||
|
|
||||||
config_git_commit=false # automatically commit changes if git repo
|
config_git_commit=false # automatically commit changes if git repo
|
||||||
config_git_push=false # automatically push changes if git repo
|
config_git_push=false # automatically push changes if git repo
|
||||||
|
|
||||||
|
|
110
burrow
110
burrow
|
@ -1,23 +1,17 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
version="v1.6.1"
|
version="v1.7.0"
|
||||||
|
|
||||||
configfiles="$HOME/.config/burrow/config $HOME/.config/burrow $HOME/.burrow"
|
configfiles="$HOME/.config/burrow/config $HOME/.config/burrow $HOME/.burrow"
|
||||||
|
|
||||||
# vars from config
|
# vars from config
|
||||||
config_dir_gopher="$HOME/gopher/"
|
config_dir_gopher="$HOME/gopher/"
|
||||||
config_dir_recipebox="recipebox"
|
|
||||||
config_dir_phlog="phlog"
|
config_dir_phlog="phlog"
|
||||||
config_dir_topics="topics"
|
|
||||||
config_gopher_server="sdf.org"
|
config_gopher_server="sdf.org"
|
||||||
config_gopher_port="70"
|
config_gopher_port="70"
|
||||||
config_gopher_root="/users/username/"
|
config_gopher_root="/users/username/"
|
||||||
config_phlog_gophermap=true
|
config_phlog_gophermap=true
|
||||||
config_phlog_usedate=true
|
config_phlog_usedate=true
|
||||||
config_recipebox_gophermap=false
|
|
||||||
config_recipebox_usedate=false
|
|
||||||
config_topics_gophermap=true
|
|
||||||
config_topics_usedate=false
|
|
||||||
config_git_commit=false
|
config_git_commit=false
|
||||||
config_git_push=false
|
config_git_push=false
|
||||||
config_autoindent=true
|
config_autoindent=true
|
||||||
|
@ -41,14 +35,12 @@ flag_help=0
|
||||||
# vars from args
|
# vars from args
|
||||||
arg_options="hvd"
|
arg_options="hvd"
|
||||||
arg_shortlist=0
|
arg_shortlist=0
|
||||||
arg_recipe=0
|
arg_gopherdir=0
|
||||||
arg_phlog=0
|
arg_phlog=0
|
||||||
arg_topic=0
|
|
||||||
arg_create_config=0
|
|
||||||
arg_edit_config=0
|
arg_edit_config=0
|
||||||
arg_update_git=0
|
arg_update_git=0
|
||||||
arg_rss=0
|
arg_rss=0
|
||||||
arg_root=0
|
arg_gophermap=""
|
||||||
|
|
||||||
# silence directory movements
|
# silence directory movements
|
||||||
push_d () {
|
push_d () {
|
||||||
|
@ -65,11 +57,8 @@ burrow [options] [commands]
|
||||||
|
|
||||||
COMMANDS:
|
COMMANDS:
|
||||||
phlog Create new phlog entry
|
phlog Create new phlog entry
|
||||||
recipe Add new recipe to box
|
gophermap Edit a gophermap
|
||||||
topic Add or update a topic
|
|
||||||
root Edit your root gophermap
|
|
||||||
rss Generate an rss feed of recent phlog entries
|
rss Generate an rss feed of recent phlog entries
|
||||||
create-config Create a default configuration file
|
|
||||||
edit-config Edit your configuration file
|
edit-config Edit your configuration file
|
||||||
update-git Silently pulls gopher git repo if it exists
|
update-git Silently pulls gopher git repo if it exists
|
||||||
|
|
||||||
|
@ -133,20 +122,39 @@ parse_input () {
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
for arg in "$@"; do
|
while test $# -gt 0
|
||||||
argc=$(printf "%s" "$arg" | tr '[:upper:]' '[:lower:]')
|
do
|
||||||
|
argc=$(printf "%s" "$1" | tr '[:upper:]' '[:lower:]')
|
||||||
case $argc in
|
case $argc in
|
||||||
"shortlist") arg_shortlist=1 ;;
|
"shortlist")
|
||||||
"phlog") arg_phlog=1 ;;
|
arg_shortlist=1
|
||||||
"recipe") arg_recipe=1 ;;
|
;;
|
||||||
"topic") arg_topic=1 ;;
|
"gophermap")
|
||||||
"create-config") arg_create_config=1 ;;
|
if [ $# -gt 1 ]; then
|
||||||
"edit-config") arg_edit_config=1 ;;
|
shift
|
||||||
"update-git") arg_update_git=1 ;;
|
arg_gophermap="$1"
|
||||||
"rss") arg_rss=1 ;;
|
else
|
||||||
"root") arg_root=1 ;;
|
arg_gophermap="/"
|
||||||
*) printf "Unknown command: %s\\n" "$arg";;
|
fi
|
||||||
|
;;
|
||||||
|
"phlog")
|
||||||
|
arg_phlog=1
|
||||||
|
;;
|
||||||
|
"gopherdir")
|
||||||
|
arg_gopherdir=1
|
||||||
|
;;
|
||||||
|
"edit-config")
|
||||||
|
arg_edit_config=1
|
||||||
|
;;
|
||||||
|
"update-git")
|
||||||
|
arg_update_git=1
|
||||||
|
;;
|
||||||
|
"rss")
|
||||||
|
arg_rss=1
|
||||||
|
;;
|
||||||
|
*) printf "Unknown command: %s\\n" "$argc";;
|
||||||
esac
|
esac
|
||||||
|
shift
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -547,7 +555,6 @@ create_config () {
|
||||||
if [ ! -f "$HOME/.config/burrow/config" ] && \
|
if [ ! -f "$HOME/.config/burrow/config" ] && \
|
||||||
[ ! -f "$HOME/.config/burrow" ] && \
|
[ ! -f "$HOME/.config/burrow" ] && \
|
||||||
[ ! -f "$HOME/.burrow" ]; then
|
[ ! -f "$HOME/.burrow" ]; then
|
||||||
|
|
||||||
config="$HOME/.config/burrow/config"
|
config="$HOME/.config/burrow/config"
|
||||||
mkdir -p "$(dirname "$config")"
|
mkdir -p "$(dirname "$config")"
|
||||||
{
|
{
|
||||||
|
@ -562,14 +569,6 @@ create_config () {
|
||||||
printf "config_phlog_usedate=true\\n"
|
printf "config_phlog_usedate=true\\n"
|
||||||
printf "config_phlog_autorss=false\\n"
|
printf "config_phlog_autorss=false\\n"
|
||||||
printf "\\n"
|
printf "\\n"
|
||||||
printf "config_dir_recipebox=\"recipebox\"\\n"
|
|
||||||
printf "config_recipebox_gophermap=false\\n"
|
|
||||||
printf "config_recipebox_usedate=false\\n"
|
|
||||||
printf "\\n"
|
|
||||||
printf "config_dir_topics=\"topics\"\\n"
|
|
||||||
printf "config_topics_gophermap=true\\n"
|
|
||||||
printf "config_topics_usedate=false\\n"
|
|
||||||
printf "\\n"
|
|
||||||
printf "config_git_commit=false\\n"
|
printf "config_git_commit=false\\n"
|
||||||
printf "config_git_push=false\\n"
|
printf "config_git_push=false\\n"
|
||||||
printf "\\n"
|
printf "\\n"
|
||||||
|
@ -580,8 +579,6 @@ create_config () {
|
||||||
printf "config_gopher_desc=\"Gopher Hole Description\"\\n"
|
printf "config_gopher_desc=\"Gopher Hole Description\"\\n"
|
||||||
printf "config_rss_num_entries=\"10\"\\n"
|
printf "config_rss_num_entries=\"10\"\\n"
|
||||||
} >> "$config"
|
} >> "$config"
|
||||||
else
|
|
||||||
printf "Configuration already exists.\\n"
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -598,7 +595,7 @@ main () {
|
||||||
parse_input "$@"
|
parse_input "$@"
|
||||||
|
|
||||||
if [ $arg_shortlist -gt 0 ]; then
|
if [ $arg_shortlist -gt 0 ]; then
|
||||||
out="phlog topic recipe rss edit-config create-config update-git -v -h -d"
|
out="phlog gophermap rss edit-config update-git -v -h -d"
|
||||||
die "${out}" 0
|
die "${out}" 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -614,11 +611,8 @@ main () {
|
||||||
set -x
|
set -x
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $arg_create_config -gt 0 ]; then
|
|
||||||
create_config
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $arg_edit_config -gt 0 ]; then
|
if [ $arg_edit_config -gt 0 ]; then
|
||||||
|
create_config
|
||||||
edit_config
|
edit_config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -628,42 +622,28 @@ main () {
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [ $arg_gopherdir -gt 0 ]; then
|
||||||
|
die "${config_dir_gopher}" 0
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $arg_update_git -gt 0 ]; then
|
if [ $arg_update_git -gt 0 ]; then
|
||||||
update_git
|
update_git
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $arg_root -gt 0 ]; then
|
if [ "$arg_gophermap" != "" ]; then
|
||||||
# If we don't have a gophermap, create one to avoid
|
# If we don't have a gophermap, create one to avoid
|
||||||
# accidentally sorting the file on first-time generation
|
# accidentally sorting the file on first-time generation
|
||||||
if [ ! -f "${config_dir_gopher}gophermap" ]; then
|
if [ ! -f "${config_dir_gopher}${arg_gophermap}gophermap" ]; then
|
||||||
touch "${config_dir_gopher}gophermap"
|
touch "${config_dir_gopher}${arg_gophermap}gophermap"
|
||||||
fi
|
fi
|
||||||
make_post "" \
|
make_post "" \
|
||||||
"" \
|
"${arg_gophermap}" \
|
||||||
true \
|
true \
|
||||||
false \
|
false \
|
||||||
true \
|
true \
|
||||||
false
|
false
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $arg_recipe -gt 0 ]; then
|
|
||||||
make_post "What is the name of your recipe? " \
|
|
||||||
"$config_dir_recipebox" \
|
|
||||||
"$config_recipebox_gophermap" \
|
|
||||||
"$config_recipebox_usedate" \
|
|
||||||
true \
|
|
||||||
false
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $arg_topic -gt 0 ]; then
|
|
||||||
make_post "What is the name of your topic? " \
|
|
||||||
"$config_dir_topics" \
|
|
||||||
"$config_topics_gophermap" \
|
|
||||||
"$config_topics_usedate" \
|
|
||||||
true \
|
|
||||||
false
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $arg_phlog -gt 0 ]; then
|
if [ $arg_phlog -gt 0 ]; then
|
||||||
make_post "Enter a title for your post: " \
|
make_post "Enter a title for your post: " \
|
||||||
"$config_dir_phlog" \
|
"$config_dir_phlog" \
|
||||||
|
|
33
burrow.1
33
burrow.1
|
@ -1,4 +1,4 @@
|
||||||
.TH BURROW 1 "01 Sep 2018" "version 1.6.1"
|
.TH BURROW 1 "24 Sep 2018" "version 1.7.0"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
burrow \- a helper for building and managing a gopher hole
|
burrow \- a helper for building and managing a gopher hole
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
|
@ -15,39 +15,16 @@ by including a
|
||||||
.I .template
|
.I .template
|
||||||
file in your phlog directory.
|
file in your phlog directory.
|
||||||
.TP
|
.TP
|
||||||
.B recipe
|
.B gophermap
|
||||||
Prompt for the name of your recipe, then open it in your default
|
Open a gophermap file relative to your gopher directory for editing,
|
||||||
$EDITOR. By default it will provide you a template, but you can override this
|
automatically stripping some special characters for easier editing of info
|
||||||
by including a
|
lines.
|
||||||
.I .template
|
|
||||||
file in your recipe box directory.
|
|
||||||
.TP
|
|
||||||
.B topic
|
|
||||||
Prompt for the name of the topic, then open it in your default
|
|
||||||
$EDITOR. By default it will provide you a template, but you can override this
|
|
||||||
by including a
|
|
||||||
.I .template
|
|
||||||
file in your topics directory.
|
|
||||||
.TP
|
|
||||||
.B root
|
|
||||||
Open your gopher hole's root gophermap for editing. This will remove any
|
|
||||||
type 'i' formatting and allow comments to be added in natural text. You will
|
|
||||||
still need to create links in the proper gophermap formatting.
|
|
||||||
.TP
|
.TP
|
||||||
.B rss
|
.B rss
|
||||||
Automatically generate an RSS feed of your most recent phlog
|
Automatically generate an RSS feed of your most recent phlog
|
||||||
entries and output it to the root of your gopher directory. This can be
|
entries and output it to the root of your gopher directory. This can be
|
||||||
automatically generated by using the config option config_phlog_autorss.
|
automatically generated by using the config option config_phlog_autorss.
|
||||||
.TP
|
.TP
|
||||||
.B create-config
|
|
||||||
Auto-generate a configuration file at
|
|
||||||
.I $HOME/.config/burrow/config.
|
|
||||||
It will be populated by the default parameters
|
|
||||||
listed below and provide an easy way to customize your configuration. At a
|
|
||||||
minimum you should update your
|
|
||||||
.I config_dir_gopher
|
|
||||||
to point to the folder on your local computer where your gopher hole resides.
|
|
||||||
.TP
|
|
||||||
.B edit-config
|
.B edit-config
|
||||||
Opens your burrow configuration file for editing if it exists.
|
Opens your burrow configuration file for editing if it exists.
|
||||||
.TP
|
.TP
|
||||||
|
|
30
burrow.d
30
burrow.d
|
@ -2,21 +2,35 @@
|
||||||
|
|
||||||
_burrow()
|
_burrow()
|
||||||
{
|
{
|
||||||
# Get basic autocomplete commands from the function itself
|
|
||||||
local helplist
|
|
||||||
helplist=$(burrow shortlist)
|
|
||||||
|
|
||||||
# Combine all the lists for autocomplete
|
|
||||||
local cur
|
local cur
|
||||||
cur=${COMP_WORDS[COMP_CWORD]}
|
cur=${COMP_WORDS[COMP_CWORD]}
|
||||||
COMPREPLY=( $( compgen -W "$helplist" -- "$cur" ) )
|
if [ "${COMP_WORDS[1]}" == "gophermap" ]; then
|
||||||
|
local gopher_dir
|
||||||
|
local gophermaps
|
||||||
|
local directories
|
||||||
|
gopher_dir=$(burrow gopherdir)
|
||||||
|
search_dir=${gopher_dir}
|
||||||
|
if [ -n "${COMP_WORDS[2]}" ]; then
|
||||||
|
if [ -d "${gopher_dir}${COMP_WORDS[2]}" ]; then
|
||||||
|
search_dir="${gopher_dir}${COMP_WORDS[2]}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
gophermaps=$(find "$search_dir" -mindepth 1 -maxdepth 1 -type f -name "gophermap" -print | sed "s|$gopher_dir||" | sed "s|gophermap$||" )
|
||||||
|
directories=$(find "$search_dir" -mindepth 1 -maxdepth 1 -type d -print | sed "s|$gopher_dir||" )
|
||||||
|
COMPREPLY=( $( compgen -W "$gophermaps $directories" -- "$cur" ) )
|
||||||
|
else
|
||||||
|
local helplist
|
||||||
|
helplist=$(burrow shortlist)
|
||||||
|
COMPREPLY=( $( compgen -W "$helplist" -- "$cur" ) )
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Detect if current shell is ZSH, and if so, load this file in bash
|
# Detect if current shell is ZSH, and if so, load this file in bash
|
||||||
# compatibility mode.
|
# compatibility mode.
|
||||||
if [ -n "$ZSH_VERSION" ]; then
|
if [ -n "$ZSH_VERSION" ]; then
|
||||||
autoload bashcompinit
|
autoload bashcompinit
|
||||||
bashcompinit
|
bashcompinit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
complete -o default -o nospace -F _burrow burrow
|
complete -o default -o nospace -F _burrow burrow
|
||||||
|
@ -25,5 +39,5 @@ complete -o default -o nospace -F _burrow burrow
|
||||||
# when the user has tab-completed the executable name and consequently
|
# when the user has tab-completed the executable name and consequently
|
||||||
# included the '.exe' suffix.
|
# included the '.exe' suffix.
|
||||||
if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
|
if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
|
||||||
complete -o default -o nospace -F _burrow burrow.exe
|
complete -o default -o nospace -F _burrow burrow.exe
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue