我为我的网络文件找到了这一个。但我不明白作者为什么要做dotfiles_old。相反,你只需移动到dotfiles。
代码:
#!/bin/bash
############################
# .make.sh
# This script creates symlinks from the home directory to any desired dotfiles in ~/dotfiles
############################
########## Variables
dir=~/dotfiles # dotfiles directory
olddir=~/dotfiles_old # old dotfiles backup directory
files="bashrc vimrc vim zshrc oh-my-zsh" # list of files/folders to symlink in homedir
##########
# create dotfiles_old in homedir
echo "Creating $olddir for backup of any existing dotfiles in ~"
mkdir -p $olddir
echo "...done"
# change to the dotfiles directory
echo "Changing to the $dir directory"
cd $dir
echo "...done"
# move any existing dotfiles in homedir to dotfiles_old directory, then create symlinks
for file in $files; do
echo "Moving any existing dotfiles from ~ to $olddir"
mv ~/.$file ~/dotfiles_old/
echo "Creating symlink to $file in home directory."
ln -s $dir/$file ~/.$file
done发布于 2014-05-17 20:35:48
使用~/dotfiles_old时,如果发现忘记使用新的花式提示符更新~/dotfiles/bashrc,可以直接从~/dotfiles_old/.bashrc复制它。
如果没有~/dotfiles_old,您在主目录中所做的任何更改都将永久丢失。
你是否在乎完全取决于你。这是为了用户的利益,而不是脚本。
发布于 2014-06-27 19:13:03
最好的方法是在$ HOME中创建文件夹dotfiles并创建指向其配置文件的符号链接。
这里有一个例子:https://github.com/vsouza/dotfiles
每个文件夹都有一个install.sh文件,负责创建符号链接。
https://stackoverflow.com/questions/20696909
复制相似问题