mirror of https://git.envs.net/envs/burrow.git
Compare commits
143 Commits
Author | SHA1 | Date |
---|---|---|
~creme | 53c02830c0 | |
James Tomasino | 459de8117e | |
creme | 6a8bbc71de | |
James Tomasino | b83e5056f1 | |
Zachary Lee Andrews | 91d6113fe3 | |
Sven | 2556d9eb40 | |
James Tomasino | 33c1aa0437 | |
creme | af7d8a31c2 | |
creme | 2b99bf98e3 | |
James Tomasino | 8658c7675c | |
creme | 404cd61586 | |
James Tomasino | 478f40ce24 | |
creme | b80a1c6789 | |
creme | 4b3d7364f9 | |
James Tomasino | 8e900ca005 | |
James Tomasino | e6442c9d6f | |
James Tomasino | 4c011fc82e | |
David Harrison | b9a2650819 | |
Munchotaur | d3289ebc94 | |
Munchotaur | 4a01b598fb | |
James Tomasino | 05021a7699 | |
James Tomasino | d83843fba6 | |
fosslinux | e671238848 | |
James Tomasino | 0b915075e5 | |
James Tomasino | f31b5ae218 | |
James Tomasino | cf9e56cc3c | |
James Tomasino | e71e2ae579 | |
James Tomasino | 84cc1efcd5 | |
James Tomasino | 045e7b8f72 | |
James Tomasino | 7782fd066d | |
James Tomasino | 39bd2c500a | |
James Tomasino | 08d172b3f9 | |
James Tomasino | 22387cc6fe | |
James Tomasino | 9f4a61b4f9 | |
James Tomasino | b646c085c1 | |
James Tomasino | 982eb95372 | |
James Tomasino | 9b6f3daeb1 | |
James Tomasino | 1c66e9297d | |
Jelle Besseling | c2eea80929 | |
James Tomasino | b6e2d6efa6 | |
James Tomasino | 95c008c31a | |
James Tomasino | 4cd0a9f498 | |
Samuel Tyler | 52ace7f214 | |
Samuel Tyler | 21688e4fd9 | |
James Tomasino | 49110809c1 | |
James Tomasino | 7158d5eae9 | |
James Tomasino | dd3a7d08d1 | |
James Tomasino | 2518e999af | |
James Tomasino | b715b663ff | |
Stephen Tudor | 516f835ad3 | |
Stephen Tudor | a8ec4d6c57 | |
Paco Esteban | d890a6ef53 | |
James Tomasino | 29253bc254 | |
James Tomasino | 7cd512a082 | |
James Tomasino | fc49cbeb90 | |
James Tomasino | d9a4f0169e | |
James Tomasino | 2cfeda0340 | |
James Tomasino | 3fed90daef | |
James Tomasino | 487574e053 | |
James Tomasino | f0f21df913 | |
Jelle Besseling | 986f3df957 | |
James Tomasino | 6dce0f1924 | |
James Tomasino | d37369df53 | |
James Tomasino | e3f15046b2 | |
James Tomasino | e81fa7d8bd | |
James Tomasino | 9b9377e401 | |
James Tomasino | 3e3bf3a552 | |
James Tomasino | 9b2e0221ca | |
James Tomasino | cbe6256862 | |
James Tomasino | e8c105a51c | |
James Tomasino | 23c2a9909f | |
James Tomasino | d2543cccab | |
James Tomasino | 28e1831369 | |
James Tomasino | 5366ac016b | |
James Tomasino | 93e1c41e9c | |
James Tomasino | 42892d8cfb | |
James Tomasino | 4d08e72352 | |
James Tomasino | 2acf982073 | |
James Tomasino | 6d29f54f93 | |
James Tomasino | 57eb27f8ad | |
James Tomasino | 2bc0894201 | |
James Tomasino | de865b1e5a | |
James Tomasino | 43f504e101 | |
James Tomasino | 2a693f66e5 | |
James Tomasino | 09b031157f | |
James Tomasino | c263bf8903 | |
James Tomasino | 34b61e9e3a | |
James Tomasino | 3d22e5d275 | |
James Tomasino | bc050454ff | |
James Tomasino | d79080ac1e | |
James Tomasino | 694e490353 | |
James Tomasino | 87ffadc19a | |
James Tomasino | 359dea788b | |
James Tomasino | b880efa992 | |
James Tomasino | 56f5c3f3f6 | |
James Tomasino | 7121dd0f29 | |
James Tomasino | 4535f8f571 | |
James Tomasino | fb193ff7b5 | |
James Tomasino | 4abc2496aa | |
James Tomasino | 3487b590ca | |
James Tomasino | 00707c3046 | |
James Tomasino | a7dc326a62 | |
James Tomasino | 488e27ea03 | |
James Tomasino | 445f6a30a9 | |
James Tomasino | e981106dcc | |
James Tomasino | 170817a1eb | |
James Tomasino | f49be1126e | |
James Tomasino | 43e903bbb6 | |
James Tomasino | 11d6b80757 | |
James Tomasino | 6c67e8f7fa | |
James Tomasino | 33ec590cfb | |
James Tomasino | 48f0f0ca0c | |
James Tomasino | 6f5bedded3 | |
James Tomasino | 3d5319afb0 | |
James Tomasino | 31bc38669f | |
James Tomasino | 416f8707b1 | |
James Tomasino | 6b683df3be | |
James Tomasino | 2403bedda8 | |
James Tomasino | b6ea90a866 | |
James Tomasino | ea10ed8356 | |
James Tomasino | 0ea68ff866 | |
James Tomasino | 496adcbf85 | |
James Tomasino | e0c264f6ce | |
James Tomasino | 7366097bf0 | |
James Tomasino | 95c1a61274 | |
James Tomasino | 2971b8a998 | |
James Tomasino | 6a00579db2 | |
James Tomasino | 39372f1d0c | |
James Tomasino | f41090af3e | |
James Tomasino | 09472ab21a | |
James Tomasino | 6ba34bf60f | |
James Tomasino | 78f3d4334d | |
James Tomasino | 6b7bc00308 | |
James Tomasino | b994822eac | |
James Tomasino | b2237e440f | |
James Tomasino | 085d5b43bc | |
James Tomasino | 4c60852713 | |
James Tomasino | e454e54c12 | |
James Tomasino | 3d1fafae7c | |
James Tomasino | 22dd803806 | |
James Tomasino | 078f626f96 | |
James Tomasino | 0b2437eb06 | |
James Tomasino | d0aab3267b |
|
@ -0,0 +1,26 @@
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: ssh
|
||||||
|
name: deploy
|
||||||
|
|
||||||
|
server:
|
||||||
|
host:
|
||||||
|
from_secret: host
|
||||||
|
user:
|
||||||
|
from_secret: username
|
||||||
|
ssh_key:
|
||||||
|
from_secret: ssh_key
|
||||||
|
|
||||||
|
clone:
|
||||||
|
disable: true
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
branch:
|
||||||
|
- master
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: deploy
|
||||||
|
commands:
|
||||||
|
- cd /opt/services/burrow
|
||||||
|
- sudo -Hu services git pull origin master
|
||||||
|
- sudo -Hu root make
|
|
@ -0,0 +1,3 @@
|
||||||
|
language: shell
|
||||||
|
script:
|
||||||
|
- bash -c 'shopt -s globstar && shellcheck burrow'
|
36
Makefile
36
Makefile
|
@ -1,33 +1,47 @@
|
||||||
PREFIX ?= /usr/local
|
PREFIX ?= /usr/local
|
||||||
BINDIR ?= $(PREFIX)/bin
|
BINDIR ?= $(PREFIX)/bin
|
||||||
MANDIR ?= $(PREFIX)/share/man
|
MANDIR ?= $(PREFIX)/share/man/man1
|
||||||
|
|
||||||
|
# Attempt to find bash completion dir in order of preference
|
||||||
ifneq ($(wildcard /etc/bash_completion.d/.),)
|
ifneq ($(wildcard /etc/bash_completion.d/.),)
|
||||||
CPLDIR ?= /etc/bash_completion.d
|
CPLDIR ?= /etc/bash_completion.d
|
||||||
else
|
|
||||||
ifneq ($(shell command -v pkg-config 2> /dev/null))
|
|
||||||
CPLDIR ?= $$(pkg-config --variable=completionsdir bash-completion)
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
HAS_BREW := $(shell command -v brew 2> /dev/null)
|
||||||
|
ifdef HAS_BREW
|
||||||
|
CPLDIR ?= $$(brew --prefix)/etc/bash_completion.d
|
||||||
|
endif
|
||||||
|
|
||||||
|
HAS_PKGCONFIG := $(shell command -v pkg-config 2> /dev/null)
|
||||||
|
ifdef HAS_PKGCONFIG
|
||||||
|
CPLDIR ?= $(shell pkg-config --variable=completionsdir bash-completion 2> /dev/null)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
install:
|
install:
|
||||||
@echo Installing the executable to $(BINDIR)
|
@echo Installing the executable to $(BINDIR)
|
||||||
@mkdir -p $(BINDIR)
|
@mkdir -p $(BINDIR)
|
||||||
@cp -f burrow $(BINDIR)/burrow
|
@install -m 755 burrow $(BINDIR)
|
||||||
@chmod 755 $(BINDIR)/burrow
|
|
||||||
@echo Installing the manual page to $(MANDIR)/man1
|
@echo Installing the manual page to $(MANDIR)/man1
|
||||||
@mkdir -p $(MANDIR)
|
@mkdir -p $(MANDIR)
|
||||||
@cp -f burrow.1 $(MANDIR)/man1/burrow.1
|
@install -m 644 burrow.1 $(MANDIR)
|
||||||
@chmod 644 $(MANDIR)/man1/burrow.1
|
ifdef CPLDIR
|
||||||
|
ifneq ($(CPLDIR),)
|
||||||
@echo Installing the command completion to $(CPLDIR)
|
@echo Installing the command completion to $(CPLDIR)
|
||||||
@cp -f burrow.d $(CPLDIR)/burrow
|
@mkdir -p $(CPLDIR)
|
||||||
@chmod 644 $(CPLDIR)/burrow
|
@install -m 644 burrow.d $(CPLDIR)/burrow
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
@echo Removing the executable from $(BINDIR)
|
@echo Removing the executable from $(BINDIR)
|
||||||
@rm -f $(BINDIR)/burrow
|
@rm -f $(BINDIR)/burrow
|
||||||
@echo Removing the manual page from $(MANDIR)/man1
|
@echo Removing the manual page from $(MANDIR)/man1
|
||||||
@rm -f $(BINDIR)/man1/burrow.1
|
@rm -f $(BINDIR)/man1/burrow.1
|
||||||
|
ifdef CPLDIR
|
||||||
|
ifneq ($(CPLDIR),)
|
||||||
@echo Removing the command completion from $(CPLDIR)
|
@echo Removing the command completion from $(CPLDIR)
|
||||||
@rm -f $(CPLDIR)/burrow
|
@rm -f $(CPLDIR)/burrow
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
.PHONY: install uninstall
|
.PHONY: install uninstall
|
||||||
|
|
107
README.md
107
README.md
|
@ -1,51 +1,63 @@
|
||||||
# burrow ![status](https://img.shields.io/badge/status-working-green.svg?style=flat-square) ![license](https://img.shields.io/badge/license-GPL3-blue.svg?style=flat-square) ![bash](https://img.shields.io/badge/Bash-4%2B-lightgrey.svg?style=flat-square)
|
# burrow ![status](https://travis-ci.com/jamestomasino/burrow.svg?branch=master) ![license](https://img.shields.io/badge/license-GPL3-blue.svg?style=flat-square)
|
||||||
|
|
||||||
**burrow** is a helper for building and managing a gopher hole.
|
**burrow** is a helper for building and managing a gopher hole.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
### Requirements
|
|
||||||
* bash 4+ (OSX: `brew install bash`)
|
|
||||||
* GNU sed (OSX: `brew install gnu-sed --with-default-names`)
|
|
||||||
* GNU getopt (OSX: `brew install gnu-getopt --with-default-names`)
|
|
||||||
|
|
||||||
### Install
|
|
||||||
|
|
||||||
`sudo make install`
|
|
||||||
|
|
||||||
_Note: On systems without admin access the binary can be run directly from the
|
_Note: On systems without admin access the binary can be run directly from the
|
||||||
git repo, but will lack `man` support and command completion._
|
git repo, but will lack `man` support and command completion._
|
||||||
|
|
||||||
|
See the [Getting Started](https://github.com/jamestomasino/burrow/wiki/Getting-Started) guide.
|
||||||
|
|
||||||
|
### Install on Linux / MacOS
|
||||||
|
|
||||||
|
`sudo make install`
|
||||||
|
|
||||||
|
### Install on BSD systems
|
||||||
|
|
||||||
|
#### FreeBSD
|
||||||
|
|
||||||
|
- Installing bash-completion via either `pkg install bash-completion` or via the `shells/bash-completion` port.
|
||||||
|
- Installing the GNU version of make via either `pkg install gmake` or the `port devel/gmake`.
|
||||||
|
- Rather than using `sudo make install`, run `sudo gmake install`.
|
||||||
|
|
||||||
|
#### OpenBSD
|
||||||
|
|
||||||
|
- Install the GNU version of make via either `pkg_add gmake` or the port `devel/gmake`.
|
||||||
|
- There is no bash-completion package or port in OpenBSD. However the source code can be found at https://github.com/scop/bash-completion
|
||||||
|
- Burrow appears to install and run without the presence of bash-completion. Exercise caution.
|
||||||
|
- As root (or via `doas`), run `gmake install`.
|
||||||
|
|
||||||
|
|
||||||
### Uninstall
|
### Uninstall
|
||||||
|
|
||||||
`sudo make uninstall`
|
`sudo make uninstall` # or gmake uninstall on BSD
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```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 create-config # generate a default config file
|
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
|
||||||
```
|
```
|
||||||
|
|
||||||
- `phlog` will prompt for the title of the post, then open it in your default
|
- `edit-config` will open your burrow configuration file for easy editing.
|
||||||
`$EDITOR`. By default it will provide you a template, but you can override this
|
|
||||||
by including a `.template` file in your phlog directory.
|
|
||||||
|
|
||||||
- `recipe` will prompt for the name of your recipe, 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 including a `.template` file in your recipe box directory.
|
|
||||||
|
|
||||||
- `topic` will prompt for the name of the topic, 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
|
remove any `type i` formatting and allow comments to be added in natural text.
|
||||||
by including a `.template` file in your topics directory.
|
You will still need to create links in the proper gophermap formatting.
|
||||||
|
|
||||||
- `create-config` gives you the same settings as you have by default without
|
- `rss` will automatically generate an RSS feed of your most recent phlog
|
||||||
a configuration file, but it provides you a starting point for customization.
|
entries and output it to the root of your gopher directory. This can be
|
||||||
|
automatically generated by using the config option `config_phlog_autorss`.
|
||||||
|
|
||||||
- `update-git` is appropriate for cron jobs to keep the gopher hole in sync.
|
- `update-git` will silently attempt to update a git repository at the location
|
||||||
|
of your gopher hole. It is appropriate for use by a cron job.
|
||||||
|
|
||||||
_`man burrow` or `burrow -h` for more information._
|
_`man burrow` or `burrow -h` for more information._
|
||||||
|
|
||||||
|
@ -53,9 +65,11 @@ _`man burrow` or `burrow -h` for more information._
|
||||||
|
|
||||||
The following locations are available for configuration:
|
The following locations are available for configuration:
|
||||||
|
|
||||||
1) `$HOME/.config/burrow/config`
|
1) `/etc/burrow/config`
|
||||||
2) `$HOME/.config/burrow`
|
2) `$XDG_CONFIG_HOME`
|
||||||
3) `$HOME/.burrow`
|
3) `$HOME/.config/burrow/config`
|
||||||
|
4) `$HOME/.config/burrow`
|
||||||
|
5) `$HOME/.burrow`
|
||||||
|
|
||||||
These files are processed in the order listed. Variables defined in multiple
|
These files are processed in the order listed. Variables defined in multiple
|
||||||
locations will use the last assigned value.
|
locations will use the last assigned value.
|
||||||
|
@ -64,22 +78,41 @@ The following options are available (defaults shown):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
config_dir_gopher="$HOME/gopher" # local path to gopher site
|
config_dir_gopher="$HOME/gopher" # local path to gopher site
|
||||||
config_dir_phlog="phlog" # relative path to phlog
|
|
||||||
config_dir_recipebox="recipebox" # relative path to recipe box
|
|
||||||
config_dir_topics="topics" # relative path to topics directory
|
|
||||||
config_gopher_server="sdf.org" # server of gopher host
|
config_gopher_server="sdf.org" # server of gopher host
|
||||||
config_gopher_port="70" # port of gopher host
|
config_gopher_port="70" # port of gopher host
|
||||||
config_gopher_root="/users/username/" # absolute path on gopher host to gopher site
|
config_gopher_root="/users/username/" # path on gopher host to gopher site
|
||||||
|
|
||||||
|
config_dir_phlog="phlog" # relative path to phlog
|
||||||
|
config_phlog_gophermap=true # phlogs use gophermap format by default
|
||||||
|
config_phlog_usedate=true # use a date-stamp on phlog posts
|
||||||
|
|
||||||
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
|
||||||
config_autoindent=true # automatically reformat gophermaps with leading spaces
|
|
||||||
# and parse links at the end of file
|
config_autoindent=true # automatically reformat gophermaps with leading "i"
|
||||||
config_autofold=false # automatically break lines at specific width
|
# types and parse links at the end of file
|
||||||
config_foldwidth=66 # width of line used for autofold
|
|
||||||
|
config_file_rss="rss.xml" # filename of RSS feed
|
||||||
|
config_gopher_name="My Gopher Hole" # used in RSS feed output
|
||||||
|
config_gopher_desc="Description" # used in RSS feed output
|
||||||
|
config_rss_num_entries="10" # number of entries to inclued in RSS feed
|
||||||
|
config_phlog_autorss=false # automatically generate RSS feed
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
_Note: This file is a valid Bash script and will be sourced upon load._
|
_Note: This file is a valid Bash script and will be sourced upon load._
|
||||||
|
|
||||||
|
## Disambiguity
|
||||||
|
|
||||||
|
There is [another burrow project](https://github.com/sloumdrone/burrow) created
|
||||||
|
by _sloumdrone_. His burrow project is a GUI gopher client. Please check it out!
|
||||||
|
|
||||||
|
There is also another project called "Burrow the Burrows" which can be found on gopher at: `gopher://kalos.mine.nu/1/burrow/index.gph`. It aims to construct and maintain a graph of the whole Gopherspace.
|
||||||
|
|
||||||
|
There is another [static site generator for gopher](https://github.com/hyperrealgopher/burrow) written in Haskell by @hyperrealgopher. It has similar features to my burrow.
|
||||||
|
|
||||||
|
_Armen_ now has a [gemini & spartan server](https://gitlab.com/armen138/burrow) named burrow.
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
Pull requests are welcome. For major changes, please open an issue first to
|
Pull requests are welcome. For major changes, please open an issue first to
|
||||||
discuss what you would like to change.
|
discuss what you would like to change.
|
||||||
|
|
51
burrow.1
51
burrow.1
|
@ -1,4 +1,4 @@
|
||||||
.TH BURROW 1 "03 Mar 2018" "version 1.2.0"
|
.TH BURROW 1 "06 Mar 2020" "version 1.7.9"
|
||||||
.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
|
||||||
|
@ -9,43 +9,54 @@ modification, and maintenance of a gopher hole.
|
||||||
.SH COMMANDS
|
.SH COMMANDS
|
||||||
.TP
|
.TP
|
||||||
.B phlog
|
.B phlog
|
||||||
Create a new phlog entry.
|
Prompt for the title of a new post, then open it in your default
|
||||||
|
$EDITOR.
|
||||||
.TP
|
.TP
|
||||||
.B recipe
|
.B gophermap
|
||||||
Add or update a recipe to the recipe box.
|
Open a gophermap file relative to your gopher directory for editing,
|
||||||
.B topic
|
automatically stripping some special characters for easier editing of info
|
||||||
Add or update a topic in your topics directory.
|
lines.
|
||||||
.TP
|
.TP
|
||||||
.B create-config
|
.B rss
|
||||||
Generates a default configuration file at
|
Automatically generate an RSS feed of your most recent phlog
|
||||||
.I ~/.config/burrow/config
|
entries and output it to the root of your gopher directory. This can be
|
||||||
if no other configuration file exists. It is populated with the default
|
automatically generated by using the config option config_phlog_autorss.
|
||||||
settings.
|
.TP
|
||||||
|
.B quickstart
|
||||||
|
Creates a new configuration file from interactive user prompts.
|
||||||
|
.TP
|
||||||
|
.B edit-config
|
||||||
|
Opens your burrow configuration file for editing if it exists.
|
||||||
.TP
|
.TP
|
||||||
.B update-git
|
.B update-git
|
||||||
If the gopher directory resides within a git repository, this action will do a
|
Silently attempt to update a git repository at the location
|
||||||
silent
|
of your gopher hole. It is appropriate for use by a cron job.
|
||||||
|
.TP
|
||||||
.B git-pull
|
.B git-pull
|
||||||
which is useful for crons.
|
which is useful for crons.
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
.B -v, --version
|
.B -v
|
||||||
Display current version information.
|
Display current version information.
|
||||||
.TP
|
.TP
|
||||||
.B -d, --debug
|
.B -d
|
||||||
Debug mode.
|
Debug mode.
|
||||||
.TP
|
.TP
|
||||||
.B -h, --help
|
.B -h
|
||||||
Show the help.
|
Show the help.
|
||||||
.SH FILES
|
.SH FILES
|
||||||
|
.I $XDG_CONFIG_HOME
|
||||||
|
,
|
||||||
.I ~/.config/burrow/config
|
.I ~/.config/burrow/config
|
||||||
,
|
,
|
||||||
.I ~/.config/burrow
|
.I ~/.config/burrow
|
||||||
,
|
,
|
||||||
.I ~/.burrow
|
.I ~/.burrow
|
||||||
|
,
|
||||||
|
.I /etc/burrow/config
|
||||||
: configuration settings for burrow. If none of these are available, the default
|
: configuration settings for burrow. If none of these are available, the default
|
||||||
configuration is loaded.
|
configuration is loaded.
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
None known.
|
None known.
|
||||||
.SH AUTHOR
|
.SH AUTHOR
|
||||||
James Tomasino <tomasino (at) sdf (dot) org>
|
James Tomasino <tomasino (at) lavabit (dot) com>
|
||||||
|
|
46
burrow.d
46
burrow.d
|
@ -1,22 +1,46 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
_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
|
||||||
|
partial_search_dir="${gopher_dir}${COMP_WORDS[2]}"
|
||||||
|
if [ -d "$partial_search_dir" ]; then
|
||||||
|
search_dir="$partial_search_dir"
|
||||||
|
else
|
||||||
|
partial_search_dir=$(dirname "$partial_search_dir")
|
||||||
|
if [ -d "$partial_search_dir" ]; then
|
||||||
|
search_dir="$partial_search_dir"
|
||||||
|
fi
|
||||||
|
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||" )
|
||||||
|
local suggestions=( $( compgen -W "$gophermaps $directories" -- "$cur" ) )
|
||||||
|
if [ "${#suggestions[@]}" == "1" ]; then
|
||||||
|
local resp=$(echo ${suggestions[0]/%\ */})
|
||||||
|
COMPREPLY=("$resp")
|
||||||
|
else
|
||||||
|
COMPREPLY=("${suggestions[@]}")
|
||||||
|
fi
|
||||||
|
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 +49,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