r/ScriptSwap • • Mar 13 '15

ITT, .bashrc and .zshrc files

ITT, we post our .bashrc and .zshrc files. Post your aliases, prompts, and functions.

Try and put 'em on Gist, Pastebin, or just paste it here.

Here's mine: https://gist.github.com/anonymous/d06f13cd913ee07d2bee

21 Upvotes

18 comments sorted by

View all comments

Show parent comment

3

u/UnchainedMundane Mar 15 '15

myps can be done as a function, which means you don't have to eval:

_myps() {
    echo -n "${PWD/$HOME/"~"}" |
        awk -F "/" '{
            if (length($0) > 30) {
                if (NF>4) print $1 "/" $2 "/.../" $(NF-1) "/" $NF;
                else if (NF>3) print $1 "/" $2 "/.../" $NF;
                else print $1 "/.../" $NF;
            }
            else print $0;
        }'
}
PS1='$(_myps)$ '

I can't quite tell what goto is meant to do at a glance, but there is a bug here:

  grep -v -E "$existing_re" $ALIAS_FILE > tmpfile

No $ before tmpfile (also, you don't need to touch it, bash will create it itself)