summaryrefslogtreecommitdiff
path: root/tw/home/files/zshrc
diff options
context:
space:
mode:
Diffstat (limited to 'tw/home/files/zshrc')
-rw-r--r--tw/home/files/zshrc18
1 files changed, 10 insertions, 8 deletions
diff --git a/tw/home/files/zshrc b/tw/home/files/zshrc
index 4f71747d..ced22a16 100644
--- a/tw/home/files/zshrc
+++ b/tw/home/files/zshrc
@@ -112,17 +112,19 @@ alias vault='VAULT_TOKEN=$(pass cern/ci/vault-root-token | head -1) \vault'
nomad-shell () {
nomad alloc exec "$1" sh -c 'export TERM=xterm-256color HOME=$NOMAD_TASK_DIR PS1="\\u@\\h \\w \\\$ "; cd; exec bash -i'
}
-restic () {
+restic.vin () {
if [ $# -eq 0 ]; then
- command restic
- echo >&2; echo 'Pass the repo name as the first parameter.' >&2
+ echo 'Pass the repo name as the first parameter.' >&2
else
- local repo=$1; shift
- echo "running: R_REPO=rest:.../$USERNAME/$repo restic $*" >&2
- # Set RESTIC_REPOSITORY here, since we have to run pass(1) to generate it.
- # RESTIC_PASSWORD_COMMAND is set separately, since it's a static string that restic will execute.
+ local repo user
+ case $1 in
+ */*) user=${1%%/*} repo=${1#*/} ;;
+ *) user=$USERNAME repo=$1 ;;
+ esac
+ shift
+ echo "running: restic -r vin.wg/$user/$repo $*" >&2
RESTIC_PASSWORD_COMMAND="pass computers/vin/restic-repos/$repo" \
- RESTIC_REPOSITORY="rest:http://timo:$(pass "computers/vin/restic-server/$USERNAME" | head -1)@vin.wg:8181/$USERNAME/$repo" \
+ RESTIC_REPOSITORY="rest:http://$user:$(pass "computers/vin/restic-server/$user" | head -1)@vin.wg:8181/$user/$repo" \
command restic "$@"
fi
}