Skip to content

Commit

Permalink
Add man page
Browse files Browse the repository at this point in the history
  • Loading branch information
ayosec committed May 24, 2020
1 parent fb27923 commit ebf6330
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 6 deletions.
20 changes: 14 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,40 @@ SPWD_VERSION ?= $(shell git describe --tags)

BUILD = build
BIN = $(BUILD)/spwd
MANPAGE= $(BUILD)/spwd.1

CFLAGS += -Wall -Wextra -Wpedantic -O2
OBJECTS := $(patsubst src/%.c,$(BUILD)/%.o,$(wildcard src/*.c))

.DEFAULT_GOAL = test
M4_DOCS = m4 -DSPWD_VERSION=$(SPWD_VERSION)

$(BUILD)/USAGE.h: src/USAGE.m4
@mkdir -p $(dir $@)
m4 -DSPWD_VERSION=$(SPWD_VERSION) $< | xxd -i > $@
.DEFAULT_GOAL = test

$(BUILD)/%.o: src/%.c $(wildcard src/*.h) $(BUILD)/USAGE.h
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c -o $@ $<

$(BUILD)/USAGE.h: doc/USAGE.m4
@mkdir -p $(dir $@)
$(M4_DOCS) $< | xxd -i > $@

$(MANPAGE): doc/spwd.1.scd
@mkdir -p $(dir $@)
$(M4_DOCS) $< | scdoc > $@

$(BIN): $(OBJECTS)
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -g -o $@ $(OBJECTS)

all: $(BIN)

clean:
rm -f $(BIN) $(OBJECTS) $(BUILD)/USAGE.h
rm -f $(BIN) $(OBJECTS) $(BUILD)/USAGE.h $(MANPAGE)
rmdir $(BUILD)

install: $(BIN)
install: $(BIN) $(MANPAGE)
install -D -s -m 0755 -o root -g root $(BIN) $(DEST)/bin/spwd
install -D -m 0644 -o root -g root $(MANPAGE) $(DEST)/share/man/man1/spwd.1

test: all
@./tests/run
Expand Down
File renamed without changes.
53 changes: 53 additions & 0 deletions doc/spwd.1.scd
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
spwd(1) "ShorterPWD SPWD_VERSION" "User Commands"

# NAME

spwd - Shorter PWD

# SYNOPSIS
spwd [OPTION]...

# DESCRIPTION

Prints the current path, trimming the parents to fit a certain width. It is
intended to be used in the prompt (*PS1* or equivalent).

*-m* _width_
Target width of the path.

*-a* _path-aliases_
Path for the aliases file.

*-L*
use PWD from environment, even if it contains symlinks

*-P*
use physical path, from *getcwd*(3)


If no option is specified, -P is assumed.

# ALIASES

spwd can replace a path prefix with an alias. To use this feature, write the
aliases in a file, and specify the path to it with the *-a* option. See
*ALIASES FORMAT* below for a description of the format.

# ALIASES FORMAT

Every line in the file defines a new alias, with the following format:

alias = path

Lines beginning with *#* are ignored. Spaces around *=* are stripped.

# EXAMPLES

Trim path to fit 40 characters:

PS1='$(spwd -m 40)\$ '


# SEE ALSO

*pwd*(1), *getcwd*(3)

0 comments on commit ebf6330

Please sign in to comment.