mirror of
https://tildegit.org/tomasino/pb.git
synced 2024-11-20 03:25:54 +01:00
added makefile, help, and command completion
This commit is contained in:
parent
94e2d6a22d
commit
c0008eab30
46
Makefile
Normal file
46
Makefile
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
PREFIX ?= /usr/local
|
||||||
|
BINDIR ?= $(PREFIX)/bin
|
||||||
|
MANDIR ?= $(PREFIX)/share/man
|
||||||
|
|
||||||
|
# Attempt to find bash completion dir in order of preference
|
||||||
|
ifneq ($(wildcard /etc/bash_completion.d/.),)
|
||||||
|
CPLDIR ?= /etc/bash_completion.d
|
||||||
|
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 ?= $$(pkg-config --variable=completionsdir bash-completion 2> /dev/null)
|
||||||
|
endif
|
||||||
|
|
||||||
|
install:
|
||||||
|
@echo Installing the executable to $(BINDIR)
|
||||||
|
@mkdir -p $(BINDIR)
|
||||||
|
@cp -f pb $(BINDIR)/pb
|
||||||
|
@chmod 755 $(BINDIR)/pb
|
||||||
|
@echo Installing the manual page to $(MANDIR)/man1
|
||||||
|
@mkdir -p $(MANDIR)
|
||||||
|
@cp -f pb.1 $(MANDIR)/man1/pb.1
|
||||||
|
@chmod 644 $(MANDIR)/man1/pb.1
|
||||||
|
ifdef CPLDIR
|
||||||
|
@echo Installing the command completion to $(CPLDIR)
|
||||||
|
@mkdir -p $(CPLDIR)
|
||||||
|
@cp -f pb.d $(CPLDIR)/pb
|
||||||
|
@chmod 644 $(CPLDIR)/pb
|
||||||
|
endif
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
@echo Removing the executable from $(BINDIR)
|
||||||
|
@rm -f $(BINDIR)/pb
|
||||||
|
@echo Removing the manual page from $(MANDIR)/man1
|
||||||
|
@rm -f $(BINDIR)/man1/pb.1
|
||||||
|
ifdef CPLDIR
|
||||||
|
@echo Removing the command completion from $(CPLDIR)
|
||||||
|
@rm -f $(CPLDIR)/pb
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: install uninstall
|
12
pb
12
pb
@ -2,10 +2,11 @@
|
|||||||
|
|
||||||
version="v.2018.08.14"
|
version="v.2018.08.14"
|
||||||
ENDPOINT="https://0x0.tilde.team"
|
ENDPOINT="https://0x0.tilde.team"
|
||||||
flag_options="hvfs::"
|
flag_options="hvfs::x"
|
||||||
flag_version=0
|
flag_version=0
|
||||||
flag_help=0
|
flag_help=0
|
||||||
flag_file=0
|
flag_file=0
|
||||||
|
flag_shortlist=0
|
||||||
data=""
|
data=""
|
||||||
|
|
||||||
SUCCESS=$(tput setaf 190)
|
SUCCESS=$(tput setaf 190)
|
||||||
@ -77,6 +78,10 @@ while true; do
|
|||||||
shift
|
shift
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
|
-x)
|
||||||
|
flag_shortlist=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
--)
|
--)
|
||||||
shift
|
shift
|
||||||
break
|
break
|
||||||
@ -102,6 +107,11 @@ if [ ${flag_help} -gt 0 ]; then
|
|||||||
die "" 0
|
die "" 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ ${flag_shortlist} -gt 0 ]; then
|
||||||
|
out="-f -v -h -s"
|
||||||
|
die "${out}" 0
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ${flag_file} -gt 0 ]; then
|
if [ ${flag_file} -gt 0 ]; then
|
||||||
if [ -z "${data}" ]; then
|
if [ -z "${data}" ]; then
|
||||||
printf "%sProvide data to upload%s\\n" "$ERROR" "$RESET"
|
printf "%sProvide data to upload%s\\n" "$ERROR" "$RESET"
|
||||||
|
43
pb.1
Normal file
43
pb.1
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
.TH PB 1 "14 August 2018" "v2018.08.14"
|
||||||
|
.SH NAME
|
||||||
|
pb \- a helper utility for using 0x0 pastebin services
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.B pb [options] (filename)
|
||||||
|
.P
|
||||||
|
.SH DESRIPTION
|
||||||
|
.B pb
|
||||||
|
provides an easy-to-use interface for uploading images
|
||||||
|
or piping output to a 0x0 pastebin service. While it
|
||||||
|
comes pre-configured with a specific pastebin, the
|
||||||
|
service endpoint can be overridden.
|
||||||
|
.SH USAGE
|
||||||
|
.TP
|
||||||
|
.B pb scores.txt
|
||||||
|
Upload "scores.txt" to the pastebin
|
||||||
|
.TP
|
||||||
|
.B echo "Secret info" | pb
|
||||||
|
Upload piped output to the pastebin
|
||||||
|
.TP
|
||||||
|
.B find . -type f -name "*.js" -print | pb -f
|
||||||
|
Upload a list of files to the pastebin individually
|
||||||
|
.B pb -s http://0x0.st scores.txt
|
||||||
|
Upload a file to a different pastebin endpoint
|
||||||
|
.SH DEPENDENCIES
|
||||||
|
None.
|
||||||
|
.SH OPTIONS
|
||||||
|
.TP
|
||||||
|
.B -f
|
||||||
|
Explicitly interpret stdin as filename or names
|
||||||
|
.TP
|
||||||
|
.B -s <server_address>
|
||||||
|
Use alternative pastebin server address
|
||||||
|
.TP
|
||||||
|
.B -v
|
||||||
|
Display current version information.
|
||||||
|
.TP
|
||||||
|
.B -h
|
||||||
|
Show the help.
|
||||||
|
.SH BUGS
|
||||||
|
None known.
|
||||||
|
.SH AUTHOR
|
||||||
|
James Tomasino <tomasino (at) lavabit (dot) com>
|
28
pb.d
Normal file
28
pb.d
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
_pb() {
|
||||||
|
# Get basic autocomplete commands from the function itself
|
||||||
|
local helplist
|
||||||
|
helplist=$(pb -x)
|
||||||
|
|
||||||
|
# Combine all the lists for autocomplete
|
||||||
|
local cur
|
||||||
|
cur=${COMP_WORDS[COMP_CWORD]}
|
||||||
|
COMPREPLY=( $( compgen -W "$helplist" -- "$cur" ) )
|
||||||
|
}
|
||||||
|
|
||||||
|
# Detect if current shell is ZSH, and if so, load this file in bash
|
||||||
|
# compatibility mode.
|
||||||
|
if [ -n "$ZSH_VERSION" ]; then
|
||||||
|
autoload bashcompinit
|
||||||
|
bashcompinit
|
||||||
|
fi
|
||||||
|
|
||||||
|
complete -o default -o nospace -F _pb pb
|
||||||
|
|
||||||
|
# The following are necessary only for Cygwin, and only are needed
|
||||||
|
# when the user has tab-completed the executable name and consequently
|
||||||
|
# included the '.exe' suffix.
|
||||||
|
if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
|
||||||
|
complete -o default -o nospace -F _pb pb.exe
|
||||||
|
fi
|
Loading…
Reference in New Issue
Block a user