Skip to content

appleshan/dotfiles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

custom linux config files managed with gnu stow

@see https://dotfiles.github.io/

     888          888     .d888 d8b 888
     888          888    d88P"  Y8P 888
     888          888    888        888
 .d88888  .d88b.  888888 888888 888 888  .d88b.  .d8888b
d88" 888 d88""88b 888    888    888 888 d8P  Y8b 88K
888  888 888  888 888    888    888 888 88888888 "Y8888b.
Y88b 888 Y88..88P Y88b.  888    888 888 Y8b.          X88
 "Y88888  "Y88P"   "Y888 888    888 888  "Y8888   88888P'

我真的很喜欢用各种可能的方式来配置我的系统。这个 repo 保存了我的原始配置。如果你刚开始,你可以用我的(我不在乎,也不介意)。

什麼是 dotfile 呢?

dotfile 就是你的那些 dot 開頭的配置文件,譬如說 .vim .vimrc .emacs.d .bashrc 。

命令行工具们有一个约定俗成的习惯:把配置文件写到用户的Home目录下面的隐藏文件里。系统用的时间一长,这样的文件就有一堆,有些你编辑过了,有些没有,并且你都不知道里面有些什么。先来看一下你有多少个这样的文件吧:

ls -ald ~/.* | grep -v ^l | tee >(wc -l)

也许你已经想到了一千种方法来折腾它们。在用户目录下面 git init 一下?这可不是什么好主意。把它们手工复制到某个地方然后手工 ln -s 回来?这也太麻烦了。然而我们现在有个叫stow的工具可以自动化处理这一切。

GNU stow 本来是为了用于管理软件包安装以及多版本共存的一个程序。它做的主要工作就是根据目录来自动建立软链接。这样就正好满足了我们的需求。首先把所有的配置文件复制到某个文件夹去,然后运行一下 stow ,它们就自动链接好了。

这样还是有些太烦了。所以 James Swineson 写了个Bash函数来自动处理这一切。

export DOTFILES=~/dotfiles

dotfiles-count() {
        pushd >/dev/null 2>&1
        cd $HOME
        ls -ald .* | grep -v ^l | tee >(wc -l)
        popd >/dev/null 2>&1
}

dotfiles-init() {
        pushd >/dev/null 2>&1
        cd $HOME
        ls -ald .$1*;
        mkdir -p $DOTFILES/$1;
        mv .$1* $DOTFILES/$1;
        stow --dir=$DOTFILES --target=$HOME -vv $1
        popd >/dev/null 2>&1
}

dotfiles-rebuild() {
        stow --dir=$DOTFILES --target=$HOME -vv $@
}

比如我们要处理来自vim的配置文件,只需要运行 dotfiles-init vim ,一切就自动完成。想用Git管理配置文件?没问题,去 $DOTFILES 下面 git init 一下。想用网盘同步?没问题,把 $DOTFILES 设置到你的网盘目录下面。想移动你的存放目录,或者在另一台机器上恢复配置?没问题,改下 $DOTFILES 然后运行 dotfiles-rebuild * 就好(如果你关掉了 Shell 并且没链接配置文件,那么祝贺你作死成功……)。

这样是不是干净多了呢?

为什么用 symlink 而不是 cp

如果把 $HOME/dotfiles 下的文件 cp 到 $HOME 下的话,我必须自己去同步这两个目录。 改了前者,需要同步到后者;改了后者,需要同步到前者。忘了同步的话,我会奇怪自己 的改动怎么不起作用;搞错同步的方向的话,我会哭鼻子。

用 symlink 的话,基本上没有这个问题。

structure

store configuration files in ~/.dotfiles folder and symlink them to ~

$ cd ~/.dotfiles
$ tree -a -L 2
.
├── dotfiles.sh
├── i3wm
│   ├── .config
│   ├── .conky
│   ├── .conkyrc
│   └── .i3
├── shell
│   ├── .oh-my-zsh
│   ├── .zshrc
│   ├── ...
...

installing

i manage symlinks with gnu stow

stow is available for all linux and most other unix like distributions via your package manager.

  • for archlinux sudo pacman -S stow
  • for ubuntu sudo apt-get install stow
  • for mac brew install stow
# navigate to your home directory
cd ~
# clone the repo:
git clone https://github.com/appleshan/dotfiles.git .dotfiles
# enter the `.dotfiles` directory
cd .dotfiles
git submodule init --recursive
# install the zsh settings
stow shell
stow vim
stow tmux
# etc, etc, etc...
# (`stow --help` get more usage)

how it works

how it works by default the stow command will create symlinks for files in the parent directory of where you execute the command. so my dotfiles setup assumes this repo is located in the root of your home directory ~/.dotfiles. and all stow commands should be executed in that directory. otherwise you’ll need to use the -d flag with the repo directory location.

to install most of my configs you execute the stow command with the folder name as the only argument.

to install my shell configs use the command:

~/.dotfiles$ stow shell

this will symlink files to ~ and various other places.

note: stow can only create a symlink if a config file does not already exist. if a default file was created upon program installation you must delete it first before you can install a new one with stow. this does not apply to directories, only files.

~/dotfiles -> 配置文件夹

dnscrypt-proxy ->    dnscrypt-proxy 配置文件
docker         ->    docker 配置文件
dunst          ->    dunst 配置文件
git            ->    git 配置文件
i3wm           ->    i3wm 配置文件
mutt           ->    mutt 配置文件
neofetch       ->    neofetch 配置文件
ranger         ->    ranger 配置文件
redshift       ->    redshift 配置文件
rime           ->    rime 配置文件
shell          ->    zsh 配置文件
sift           ->    sift 配置文件
tmux           ->    tmux 配置文件
tor            ->    tor 配置文件
unbound        ->    unbound 配置文件
urxvt          ->    urxvt 配置文件
wakatime       ->    wakatime 配置文件
X11            ->    Xresources 配置文件
polybar        ->    polybar 配置文件
rofi           ->    rofi 配置文件

可选安装软件

*字体
ttf-monaco                  -> 一款很棒的等宽字体(AUR)
ttf-font-awesome            -> fontawesome字体(AUR)

*桌面
lightdm(lightdm-gtk-greeter)-> 启动管理器
i3-gaps                     -> WM桌面
xrander                     -> 分辨率调整
picom                       -> 特效合成器(窗口透明)
lxappearance                -> 主题管理
polybar                     -> 状态栏(AUR)polybar-git
arc-theme                   -> Gtk主题(AUR)
numix-icon-theme-git        -> Numix图标(AUR)
dunst                       -> 通知管理器

*生产工具
termite                     -> 终端管理器
visual-studio-code          -> IDE编辑器(AUR)
gvim                        -> 编辑器
zsh                         -> 使用 zsh + oh-my-zsh + power10k

*日常软件
rofi                        -> 程序启动器
thunar                      -> 文件管理器(GUI)
gvfs-smb                    -> Thunar增加smaba服务
ranger                      -> 文件管理(终端)
chromium                    -> 浏览器
pepper-flash                -> Chromium的Flash支持(AUR)
telegram                    -> 聊天软件(AUR)
evince                      -> PDF查看软件
thunderbird                 -> 邮件查看
mplayer                     -> 视频播放器(终端)
shadowsocks-libev           -> sock5 代理
mpd                         -> 音乐播放器后端
moc/ncmpcpp                 -> 音乐播放器前端
fcitx5-rime                 -> 输入法
redshift                    -> 护眼
nitrogen, feh               -> 壁纸设置器
xfce4-power-manager         -> 电源管理器
flameshot                   -> 截图工具
qv2ray                      -> 科学上网工具
clipIt                      -> 剪切板管理器
i3lock-fancy-multimonitor   -> 锁屏管理器
zathura                     -> pdf 阅读器
nvim                        -> 文本编辑器
doom-emacs                  -> 文本编辑器

*系统管理
yaourt                      -> 包管理
alsa                        -> 声卡
networkmanager              -> 网络管理

General Information

ShellWM / DEEditorTerminalMultiplexerCompositorAudioMonitorMailIRC
bash / zshi3wmEmacstermite / urxvttmuxpicompulseaudiocustom

reference