小编Del*_*aIV的帖子

我应该在 .bashrc 还是 .profile 中放置别名?

我希望每次打开 shell 时都可以使用以下别名:

export ZONE="us-eastern1-c"
export INSTANCE_NAME="myInstance"
alias gc='gcloud compute ssh --zone=$ZONE jupyter@$INSTANCE_NAME -- -L 8080:localhost:8080'
Run Code Online (Sandbox Code Playgroud)

我应该把它放进去.bashrc还是.profile?另外,扫描.bashrc我发现:

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi
Run Code Online (Sandbox Code Playgroud)

那么,这里的最佳做法是什么?我应该将别名(所需的环境变量)放在第三个文件中.bash_aliases吗?我不是配置文件扩散的忠实粉丝,但如果使用这.bash_aliases是最佳实践,我会这样做。

command-line bash alias environment-variables bashrc

7
推荐指数
1
解决办法
3981
查看次数