简体   繁体   中英

Including/Importing aliases and functions for both bash and zsh

I have a directory of functions and aliases I'd like to include for both bash and zsh terminal invocations (So I don't need to put every function and alias into every separate script and to facilitate organization/tidying of .rc files)

What I've tried so far hasn't worked. Just setting this out for further suggestions.

For zsh I'm using

if [ -d ~/.zsh.d ]; then
    for i in ~/.zsh.d/*.sh; do
        if [ -r $i ]; then
            . $i
        fi
    done
    unset i
fi

Should work for bash, too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM