I wanted to make a .zshrc alias with the help of these previous aliases present to make an alias to convert a compressed gpg to its original uncompressed folder or file... However, I am facing this issue which can not seem to find a fix.
The alias used:
# Alias to decrypt and extract a .tar.gz.gpg file
alias ungpgextract='gpg --output "${1%.gpg}" --decrypt "$1" && extract "${1%.gpg}"'
Also tried with these but they did not work:
# Alias to decrypt and extract a .tar.gz.gpg file
alias ungpgextract='output_file="${1%.gpg}"; gpg --output "$output_file" --decrypt "$1" && extract "$output_file"'
# Alias to decrypt and extract a .tar.gz.gpg file
alias ungpgextract='gpg --decrypt --output ${1%.gpg} $1 && extract ${1%.gpg}'
Error message appeared even though the dir
has the folder private.tar.gz.gpg
:
❯ ungpgextract private.tar.gz.gpg
gpg: can't open '': No such file or directory
gpg: decrypt_message failed: No such file or directory
These are the existing alias/function use them to your need:
# Alias's for archives
alias mktar='tar -cvf'
alias mkbz2='tar -cvjf'
alias mkgz='tar -cvzf'
alias untar='tar -xvf'
alias unbz2='tar -xvjf'
alias ungz='tar -xvzf'
# Extracts any archive(s) (if unp isn't installed)
extract() {
for archive in "$@"; do
if [ -f "$archive" ]; then
case $archive in
*.tar.bz2) tar xvjf $archive ;;
*.tar.gz) tar xvzf $archive ;;
*.bz2) bunzip2 $archive ;;
*.rar) rar x $archive ;;
*.gz) gunzip $archive ;;
*.tar) tar xvf $archive ;;
*.tbz2) tar xvjf $archive ;;
*.tgz) tar xvzf $archive ;;
*.zip) unzip $archive ;;
*.Z) uncompress $archive ;;
*.7z) 7z x $archive ;;
*) echo "don't know how to extract '$archive'..." ;;
esac
else
echo "'$archive' is not a valid file!"
fi
done
}
Please, I earnestly request you to suggest a way to solve this problem.