项目作者: algono

项目描述 :
My dotfiles for Ubuntu (WSL 2)
高级语言: Shell
项目地址: git://github.com/algono/dotfiles.git
创建时间: 2020-10-25T16:39:47Z
项目社区:https://github.com/algono/dotfiles

开源协议:

下载


Dotfiles

Table of contents

Dependencies

System Packages

Ubuntu

  • autojump (Ubuntu 20.10 or earlier)
  • zoxide (Ubuntu 21.04 or later)
  • neofetch
  • zsh
  • zsh-syntax-highlighting
  • zsh-autosuggestions
  • cargo (Ubuntu 20.04 or earlier)
  • eza (Ubuntu 20.10 or later)
  • bat

Arch

Pacman
AUR

Git repositories

(These are NOT needed for arch users - There are already arch packages for them)

Installation script

Ubuntu

Automatic

Script

Manual
  1. # ---
  2. # Ubuntu 20.04 or earlier
  3. sudo apt install cargo
  4. cargo install eza
  5. # Ubuntu 20.10 or later
  6. sudo apt install eza
  7. # ---
  8. # ---
  9. # Ubuntu 20.10 or earlier
  10. sudo apt install autojump
  11. # Ubuntu 21.04 or later
  12. sudo apt install zoxide
  13. # ---
  14. sudo apt install neofetch bat zsh zsh-syntax-highlighting zsh-autosuggestions
  15. git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k

For the MesloLGS NF font, it’s probably better to just follow the instructions from the powerlevel10k README.

Arch

Automatic

Script

Manual

(these commands use paru to install AUR packages)

  1. sudo pacman -S zoxide neofetch eza bat zsh zsh-syntax-highlighting zsh-autosuggestions zsh-theme-powerlevel10k
  2. paru -S ttf-meslo-nerd-font-powerlevel10k

Change shell to ZSH (optional)

  1. chsh $USER -s /bin/zsh

How to clone this repo

Packages needed

This method requires stow for creating symlinks and ed for custom .bashrc support.

Note: The automatic scripts for installing dependencies also install these packages.

Ubuntu

  1. sudo apt install stow ed

Arch

  1. sudo pacman -S --needed stow ed

Script

Automatic

Script

Manual

  1. git clone https://github.com/algono/dotfiles ~/dotfiles
  2. if [ -f ~/.bashrc ]; then mv -f ~/.bashrc ~/dotfiles/bash
  3. elif [ -f /etc/skel/.bashrc ]; then cp -f /etc/skel/.bashrc ~/dotfiles/bash
  4. elif uname -r | grep -iq manjaro; then cp ~/dotfiles/.bash-presets/.bashrc-manjaro ~/dotfiles/bash/.bashrc
  5. else cp ~/dotfiles/.bash-presets/.bashrc-wsl ~/dotfiles/bash/.bashrc
  6. fi
  7. [ -f ~/.zshrc ] && mv ~/.zshrc ~/.zshrc.bak
  8. ed ~/dotfiles/bash/.bashrc < ~/dotfiles/.patches/bashrc-patch.ed
  9. find ~/dotfiles/* -maxdepth 1 -name ".*" -o -type d -prune -printf "%f\n" | xargs /usr/bin/stow -d ~/dotfiles -t ~

Explanation

Clone repo in dotfiles directory

  1. git clone https://github.com/algono/dotfiles ~/dotfiles

If there is a custom .bashrc (either in the user’s personal folder or in the system’s skel folder), use it as a base.
As a fallback, if the system is detected as manjaro, use the default manjaro .bashrc, and if it wasn’t use the default WSL one

  1. if [ -f ~/.bashrc ]; then mv -f ~/.bashrc ~/dotfiles/bash
  2. elif [ -f /etc/skel/.bashrc ]; then cp -f /etc/skel/.bashrc ~/dotfiles/bash
  3. elif uname -r | grep -iq manjaro; then cp ~/dotfiles/bash/.bashrc-manjaro ~/dotfiles/bash/.bashrc
  4. else cp ~/dotfiles/bash/.bashrc-wsl ~/dotfiles/bash/.bashrc
  5. fi

If there is a .zshrc file in the home folder, rename it
(stow would fail if it finds a file there)

  1. [ -f ~/.zshrc ] && mv ~/.zshrc ~/.zshrc.bak

Use the ed command to apply the relevant changes to the custom .bashrc file (Note: You should backup ~/.bashrc first if you have that file, as this method has not been extensively tested and it could break it)

  1. ed ~/dotfiles/bash/.bashrc < ~/dotfiles/.patches/bashrc.patch.ed

Create symlinks for our dotfiles into the home directory
(this command matches all non-hidden directories inside the ‘dotfiles’ folder)

  1. find ~/dotfiles/* -maxdepth 1 -name ".*" -o -type d -prune -printf "%f\n" | xargs /usr/bin/stow -d ~/dotfiles -t ~

The last command didn’t work. It told me that some files were going to be overwritten and failed.

If you already have some of the files from this repo, the last command will warn you and won’t run.

Stow does not have any option to overwrite files, so you can either make backups of these files (example: mv .dotfile .dotfile.bak), or just delete them, and then re-run the last command.