Simple Command Line Password Manager
I'll not address the security analysis; I'll assume you've done threat modelling and are happy with the overall approach.



Instead of a chain of if/elif all testing the same variable, the natural approach is a switch.  I'll also take advantage of ${:-} to default the argument:

case "${1:-d}" in
    d)
        # Decrypt
        # (commands)
        ;;
    e)
        # Encrypt
        # (commands)
        ;;
    i)
        # Initialize
        # (commands)
        ;;
    *)
        # invalid
        exec &gt;&amp;2
        echo "Usage: $0 [option]"
        echo "Options:"
        echo "  d - decrypt [default]"
        echo "  e - encrypt"
        echo "  i - initialize"
        exit 1
        ;;
esac


Note that I've sent the error message to error output (&amp;2) and exited with an error code.  Actually, this should really be return 1 since it's a function rather than a complete script.



In the decrypt code, you use pushd and popd.  These are suited to interactive use, but are best left alone in scripts or functions (that's why you discovered that you need to redirect their output).  Instead, you can use a sub-shell:

(cd ~; commands... )


or use full paths.  In this case, we want tar to output to ~, and we can tell it to do so, using its -C option:

openssl -in ~/.kruptos.tar.gz.aes | tar -C ~ -xz -f -




Finally, you can avoid duplication by putting paths that are used more than once into variables.  This protects you against mis-typing any of them, and makes it easier if you should ever want to change them.

Modified code

Here's what I have, after applying the above changes:

function kruptos
{
    local dir=~/.kruptos
    local file=~/.kruptos.tar.gz.aes
    local keyfile="$dir/.phrazein"

    case "${1:-d}" in
        d)
            # Decrypt
            openssl aes-256-cbc -d  -in  \
                | tar -C "$dir" xfz - \
                &amp;&amp; rm "$file"
            ;;
        e)
            # Encrypt
            tar -C "$dir" cfz - . \
                | openssl aes-256-cbc -out "$file" -kfile "$keyfile" \
                &amp;&amp; rm -r "$dir"
            ;;
        i)
            # Initialize
            mkdir "$dir"
            echo pswd &gt;"$keyfile"
            ;;
        *)
            # invalid
            exec &gt;&amp;2
            echo "Usage: $0 [option]"
            echo "Options:"
            echo "  d - decrypt [default]"
            echo "  e - encrypt"
            echo "  i - initialize"
            return 1
            ;;
    esac
}