-
-
Save wouterdebie/a8f30e7326e9acb5738d27a1de2e67e6 to your computer and use it in GitHub Desktop.
aws-vault wrapper that supports path completion (zsh)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
profile=$1 | |
cmd=$2 | |
src=$3 | |
dst=$4 | |
function _aws { | |
local profile=$1 | |
local cmd=$2 | |
local src=$3 | |
local dst=$4 | |
aws-vault exec ${profile} -- aws s3 ${cmd} ${src} ${dst} | |
} | |
case $cmd in | |
(cat) | |
_aws ${profile} cp s3://${src} - | |
;; | |
(complete) | |
if [[ $src != *\/* ]]; then | |
_aws ${profile} ls | awk '{print $NF}' | xargs -I {} echo '{}/' | |
else | |
dir=$(dirname $src) | |
if [[ ${dir} == "." ]] || [[ $src == *\/ ]]; then | |
prefix=$src | |
else | |
prefix="${dir}/" | |
fi | |
_aws ${profile} ls $prefix | awk '{print $NF}' | xargs -I {} echo "$prefix{}" | |
fi | |
;; | |
(login) | |
(*) | |
_aws ${profile} ${cmd} ${src} ${dst} | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment