Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ install:
@install -v -d "$(DESTDIR)$(SYSTEM_EXTENSION_DIR)/"
@install -v -m0755 src/tail.bash "$(DESTDIR)$(SYSTEM_EXTENSION_DIR)/tail.bash"
@install -v -m0755 src/tailedit.bash "$(DESTDIR)$(SYSTEM_EXTENSION_DIR)/tailedit.bash"
@install -v -m0755 src/tailclip.bash "$(DESTDIR)$(SYSTEM_EXTENSION_DIR)/tailclip.bash"
@install -v -d "$(DESTDIR)$(BASHCOMPDIR)/"
@install -v -m 644 completion/pass-tail.bash.completion "$(DESTDIR)$(BASHCOMPDIR)/pass-tail"
@echo
Expand All @@ -30,11 +31,13 @@ uninstall:
@rm -vrf \
"$(DESTDIR)$(SYSTEM_EXTENSION_DIR)/tail.bash" \
"$(DESTDIR)$(SYSTEM_EXTENSION_DIR)/tailedit.bash" \
"$(DESTDIR)$(SYSTEM_EXTENSION_DIR)/tailclip.bash" \
"$(DESTDIR)$(MANDIR)/man1/pass-tail.1" \
"$(DESTDIR)$(BASHCOMPDIR)/pass-tail"

lint:
shellcheck -s bash src/tail.bash
shellcheck -s bash src/tailedit.bash
shellcheck -s bash src/tailclip.bash

.PHONY: install uninstall lint
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ Username: AmazonianChicken@example.com

`pass tailedit <password file>` opens the password file in the editor omitting the first line. When saving the first line is prepended.

## pass tailclip

`pass tailclip <password file>` displays the whole password file except for the first line (like `pass tail`), but also copies the first line to the clipboard (like `pass show -c <password file>`).

## Installation

- Enable password-store extensions by setting ``PASSWORD_STORE_ENABLE_EXTENSIONS=true``
Expand Down
5 changes: 5 additions & 0 deletions completion/pass-tail.bash.completion
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
PASSWORD_STORE_EXTENSION_COMMANDS+=(tail)
PASSWORD_STORE_EXTENSION_COMMANDS+=(tailedit)
PASSWORD_STORE_EXTENSION_COMMANDS+=(tailclip)

__password_store_extension_complete_tail() {
_pass_complete_entries 1
Expand All @@ -8,3 +9,7 @@ __password_store_extension_complete_tail() {
__password_store_extension_complete_tailedit() {
_pass_complete_entries 1
}

__password_store_extension_complete_tailclip() {
_pass_complete_entries 1
}
9 changes: 9 additions & 0 deletions man/pass-extension-tail.1
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ tailedit
[
.I pass-name
]
.br
.B pass
tailclip
[
.I pass-name
]

.SH DESCRIPTION

Expand All @@ -34,6 +40,9 @@ Display the whole password file except for the first line. This allows users to
.TP
\fBtailedit\fP \fIpass-name\fP
Open the password file in the editor omitting the first line. When saving the first line is prepended.
.TP
\fBtailclip\fP \fIpass-name\fP
Display the whole password file except for the first line, and copy the first line to the clipboard. This is equivalent to the combination of \fBpass show -c\fP \fIpass-name\fP and \fBpass tail\fP \fIpass-name\fP

.SH SEE ALSO
.BR pass (1)
Expand Down
21 changes: 21 additions & 0 deletions src/tailclip.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

[[ $# -ne 1 ]] && die "Usage: $PROGRAM $COMMAND pass-name"

path="${1%/}"

# Get the full content
content=$(cmd_show "$path")
[[ $? -ne 0 ]] && die "$content"

# Get the first line (password)
password=$(echo "$content" | head -n 1)
# Get the rest
rest=$(echo "$content" | tail -n +2)

# Display the rest
echo "$rest"

# Clip password
clip "$password" "$path" >&2