在Bash Profile中定义别名可以简化命令的使用,但在更换或升级电脑时,这些别名可能会丢失。为了防止这种情况的发生,我们可以备份Bash Profile中的别名。
nano ~/.bash_profile
alias backup_alias='cp -p ~/.bash_profile ~/bash_profile_backup_$(date +%Y.%m.%d.%H.%M.%S)'
source ~/.bash_profile
backup_alias
备份文件将保存在您的主目录中,并且随着时间的推移,您将拥有多个备份文件以供选择。
上一篇:备份宝石安装失败。