dotfiles/README.org
2019-11-03 12:36:34 +01:00

42 KiB
Raw Blame History

Phundraks dotfiles

Presentation

https://cdn.rawgit.com/syl20bnr/spacemacs/442d025779da2f62fc86c2082703697714db6514/assets/spacemacs-badge.svg

This is my collection of dotfiles for my daily GNU/Linux environment, tweaked to my liking. If you wish to get the same setup as mine, follow the instructions below.

As you can see, I personally use fish as my shell of choice, and Emacs using Spacemacs (still with Emacs keybinding) as my main text editor.

I also use Resloveds fork of i3-gaps with two polybar bars and Tryone144s fork of Compton. The colors scheme for rofi, Emacs and polybar are chosen from the wallpapers using pywal.

Screenshots

/phundrak/dotfiles/media/commit/f1d40e2b1c542c6117c85a40c202a2398c283e5e/img/neofetch.png
Desktop with Neofetch in the terminal
/phundrak/dotfiles/media/commit/f1d40e2b1c542c6117c85a40c202a2398c283e5e/img/emacs.png
Desktop with Emacs opened
/phundrak/dotfiles/media/commit/f1d40e2b1c542c6117c85a40c202a2398c283e5e/img/rofi.png
Desktop with Rofi

Features

  • Emacs configuration perfectly tailored for my own use
  • Beautiful and comfy i3 and polybar configuration
  • And enough information below to get basically the same distro install as I have on my main computer and my travel laptop.

Most of the org files you will find in this repos are the actual source code of much of my config files. For instance, the Execute bootstrap subpart of this file exports almost all of its code snippets to .yadm/bootstrap thanks to M-x org-babel-tangle from within Emacs. Below I will also present and comment some of my short config files which do not deserve to have a full org file dedicated to them.

Custom scripts in PATH

I have written some scripts that help me daily accomplish some simple tasks, like mounting and unmounting a drive or Android device, an emoji picker, a utility to set up my Wacom tablet, and so on. You can find them stored in .local/bin along with their detailed explanation in the README placed in the same folder —which is actually their source code once the org-mode file gets tangled.

Email signature

This file gets inserted automatically at the end of my emails.

  Lucien “Phundrak” Cartier-Tilet
  https://phundrak.fr (Français)
  https://en.phundrak.fr (English)

  Pensez à notre planète, avez-vous vraiment besoin dimprimer ce courriel ?
  Please mind our planet, do you really need to print this email?

Fish configuration with useful abbreviations

You can also find in .config/fish my Fish shell configuration, which contains my usual abbreviations. Most of its configuration is made with fisher though, and this is shown below in Install fisher.j

Nano

Although it is a very simple piece of software, nano does offer some customization. Here is mine.

Configuration

When soft line wrapping is enabled, make it wrap lines at blank characters (tabs and spaces) instead of always at the edge of the screen.

set atblanks

Automatically indent a newly created line to the same number of tabs and/or spaces as the previous line (or as the next line if the previous line is the beginning of a paragraph).

  set autoindent

When saving a file, create a backup file by adding a tilde (~) to the file's name. And make and keep not just one backup file, but make and keep a uniquely numbered one every time a file is saved — when backups are enabled with set backup or --backup or -B. The uniquely numbered files are stored in the directory ~/.cache/nano/backups/.

  set backup
  set backupdir /home/phundrak/.cache/nano/backups/

Use bold instead of reverse video for the title bar, status bar, key combos, function tags, line numbers, and selected text. This can be overridden by setting the options titlecolor, statuscolor, keycolor, functioncolor, numbercolor, and selectedcolor.

set boldtext

Do case-unsensitive searches by default.

  unset casesensitive

Constantly display the cursor position in the status bar. This overrides the option quickblank.

set constantshow

Display line numbers to the left of the text area.

set linenumbers

Do regular-expression searches by default. Regular expressions in nano are of the extended type (ERE).

set regexp

Make the Home key smarter. When Home is pressed anywhere but at the very beginning of non-whitespace characters on a line, the cursor will jump to that beginning (either forwards or backwards). If the cursor is already at that position, it will jump to the true beginning of the line.

set smarthome

Enable soft line wrapping for easier viewing of very long lines.

set softwrap

Use a tab size of a certain amount of columns. The value of number must be greater than 0. The default value is 8.

set tabsize 2

Convert typed tabs to spaces. Sue me.

  set tabstospaces

Remove trailing whitespace from wrapped lines when automatic hard-wrapping occurs or when text is justified.

set trimblanks

Save a file by default in Unix format. This overrides nano's default behavior of saving a file in the format that it had. (This option has no effect when you also use set noconvert.)

set unix

Included configuration file

Nano gives the opportunity to include some files located elsewhere. This is why I added this repo as a submodule of my dotfiles so I can access a lot of them at the same time. Since the submodule is cloned in ~/.config/nanorc, we can add only one line to include all of the .nanorc files.

  include ~/.config/nanorc/*.nanorc

Global gitignore

Sometimes, there are some lines that always reappear in gitignores. So, instead of always adding them, let git now that some elements are to be ignored by default, hence the ~/.gitignore_global file. First, we dont want nanos backup files.

  ~*

And output binaries generated by gcc and the likes arent welcome either.

  ,*.out

Rustfmt

In my .rustfmt.toml, you can find some custom rules on how my Rust code should be formatted.

First, we are using the 2018 edition of Rust.

edition = "2018"

The maximum length of enum variant having discriminant, that gets vertically aligned with others. Variants without discriminants would be ignored for the purpose of alignment.

Note that this is not how much whitespace is inserted, but instead the longest variant name that doesn't get ignored when aligning.

enum_discrim_align_threshold = 20

Put single-expression functions on a single line.

fn_single_line = true

Format code snippet included in doc comments.

format_code_in_doc_comments = true

Format string literals where necessary.

format_strings = true

Use tab characters for indentation, spaces for alignment.

hard_tabs = true

Maximum width of each line

max_width = 80

Merge multiple imports into a single nested import.

merge_imports = true

My newline style will always be Unix.

newline_style = Unix

Convert /* */ comments to // comments where possible.

normalize_comments = true

Convert #![doc] and #[doc] attributes to //! and /// doc comments.

normalize_doc_attributes = true

Reorder impl items. type and const are put first, then macros and methods.

reorder_impl_items = true

Report FIXME items in comments.

report_fixme = "Always"

Report TODO items in comments.

todo = "Always"

The maximum diff of width between struct fields to be aligned with each other.

struct_field_align_threshold = 20

Number of spaces per tab.

tab_spaces = 2

Break comments to fit on the line.

wrap_comments = true

Tmux configuration

You can find my tmux configuration in tmux.org. It depends on the submodule .tmux by Gregory Pakosz.

Xresources

My Xresources file is very short. Indeed, it only contains two lines which are dedicated to my st terminal to set its font and shell. The font is set as follows.

  st.font: Source Code Pro for Powerline:style=book

And I will set my shell like this:

  st.shell: /usr/bin/fish

I used to have lines dedicated to UXTerm and URxvt, but I cast them out of my system.

Dependencies

Of course, some dependencies are needed for my dotfiles to work well. Here is a non-exhaustive list of software needed by these configuration files:

And some other stuff scattered around in my dotfiles.

BTW, I use Arch.

Installation

Here will be presented what I do to get my system up and running on a fresh Arch Linux install. These installation instructions were written in order to get an Arch Linux distribution up and running with the same configuration as my main computers and my travelling laptops configuration.

Install Arch Linux

I usually install Arch from the vanilla ISO, however I began using archfi to install easily the distro (Ive done it so many times, I know how it works now). Usually, my distros will be installed on at least two partitions, one dedicated to /home, the other to the root partition /.

If the computer supports EFI bootloaders, the EFI partition will be mounted on /boot. I generally use rEFInd as my boot manager, but if you are more comfortable with another one, just install what you want. Be aware that if you format your /boot partition, you will delete all boot managers that already exist; so, if you are dual-booting, DO NOT FORMAT IT. Yes, I made the mistake of wiping the Windows boot manager.

The swap partition is always at least 4GB large, and I should have a total of 12GB of combined RAM and swap. This means on my main computer I have 16GB of RAM and 4GB of swap, but on my thinkpad I have 4GB of RAM and 8GB of swap.

Get the latest live system with fast mirrors

When you boot into the live ISO, execute the following command:

  pacman -Sy reflector
  reflector --country France --country Germany --latest 200 \
            --protocol http --protocol https --sort rate \
            --save /etc/pacman.d/mirrorlist

This will update the packages from your live ISO, and you will get the best mirrors for your installation. Of course, change the countries accordingly to your location.

Install the system

Then you can use a custom script to ease your installation of Arch if you do not wish to do it manually. Personally, Ive done it several times already, I know how the distro works, I just want to be able to install my distro quickly now.

  wget archfi.sf.net/archfi
  # Or from matmoul.github.io/archfi if SourceForge is down
  sh archfi

Then, follow the instructions and install Arch Linux. Take the opportunity to install as many packages as you need, mainly yay which I use as my package manager (it is just a wrapper for pacman) and AUR helper, and pacman-contrib which will help us installing some packages later.

Once your system is installed, reboot and remove your installation media from your computer.

Install basic packages

We will need some basic packages in order to run the bootstrap file. So, lets install fish (our shell running the script) and git.

  sudo pacman -Sy fish git yadm

Execute bootstrap

yadm comes with a very handy feature: its bootstrap script. We can execute it by running the following command:

  yadm bootstrap

Notice these two header files, we can see this is a fish script, hence why we need fish (which is my daily shell anyway).

  #!/usr/bin/fish
  # -*- mode: fish -*-

Lets take a look at what it does.

Get a correct keyboard layout

I use mainly the bépo layout, a French keyboard layout inspired by Dvorak layouts, however I sometimes need to switch back to the standard French AZERTY or the American QWERTY layout, so I make it so the Menu key switches for me my layout between these three. This makes it so my xorg configuration of my keyboard looks like this:

  set keyboardconf \
  'Section "InputClass"
          Identifier "system-keyboard"
          MatchIsKeyboard "on"
          Option "XkbLayout" "fr,fr,us"
          Option "XkbModel" "pc104"
          Option "XkbVariant" "bepo,,"
          Option "XkbOptions" "grp:menu_toggle"
  EndSection'

So, lets set it as our keyboard configuration.

  printf "\n# Set keyboard layout #########################################################\n\n"
  echo $keyboardconf | sudo tee /etc/X11/xorg.conf.d/00-keyboard.conf

Set our locale

I use two main locales, the French and US UTF-8 locales, and I like to keep the Japanese locale activated just in case.

  set mylocales "en_US.UTF-8 UTF-8" "fr_FR.UTF-8 UTF-8" "ja_JP.UTF-8 UTF-8"

Lets enable these.

  printf "\n# Set our locale ##############################################################\n\n"
  for item in $mylocales
      if test (grep -e "#$item" /etc/locale.gen)
          sudo sed -i "/$item/s/^#//g" /etc/locale.gen
      end
  end

This is my configuration I usually use when it comes to my locale.

  set localeconf "LANG=en_US.UTF-8
  LC_COLLATE=C
  LC_NAME=fr_FR.UTF-8
  LC_NUMERIC=fr_FR.UTF-8
  LC_IDENTIFICATION=fr_FR.UTF-8
  LC_TELEPHONE=fr_FR.UTF-8
  LC_MONETARY=fr_FR.UTF-8
  LC_PAPER=fr_FR.UTF-8
  LC_ADDRESS=fr_FR.UTF-8
  LC_TIME=fr_FR.UTF-8
  LC_MEASUREMENT=fr_FR.UTF-8"

Lets set it as our systems locale.

  echo $localeconf | sudo tee /etc/locale.conf

Now we can generate our locale!

  printf "\n# Generate locale #############################################################\n\n"
  sudo locale-gen

Create some folders

Lets create some folders we might need for mounting our drives, Android devices and CDs.

  printf "\n# Create directories for mounting #############################################\n\n"
  sudo mkdir -p /mnt/{USB,CD,Android}
  sudo chown $USER:(id -g $USER) /mnt/{USB,CD,Android}

We also need the following folder for our nano backups.

  mkdir -p $HOME/.cache/nano/backups

Set users shell to fish

First of all, the bootstrap shell will set the users shell to fish.

  printf "\n# Set fish as the default shell ###############################################\n\n"
  chsh -s /usr/bin/fish

Install yay if it isnt already installed

Now well need to be sure yay, our AUR helper, is installed on our system. If it is, we dont need to to anything. However, if it isnt, well install it manually.

  if ! test which yay
      printf "\n# Installing yay ##############################################################\n\n"
      cd
      mkdir -p fromGIT
      cd fromGIT
      git clone https://aur.archlinux.org/yay.git
      cd yay
      makepkg -si --noconfirm
  else
      printf "\n# yay already installed #######################################################\n\n"
  end

Setting up Emacs: Installing Spacemacs

Now, the first thing we want to do with Emacs is install its Spacemacs distribution. Well clone its develop branch into ~/.emacs.d. We need to do this prior to our dotfiles cloning because of some submodules that are cloned within our ~/.emacs.d directory, and git wont let us clone Spacemacs in an already existing and non-empty directory. To make sure it isnt one, lets delete any potentially existing ~/.emacs.d directory:

  printf "\n# Installing Spacemacs ########################################################\n\n"
  rm -rf ~/.emacs.d

Now we can clone Spacemacs:

  git clone --single-branch --branch develop https://github.com/syl20bnr/spacemacs ~/.emacs.d

And we can restore what might have been deleted in our ~/.emacs.d/private directory:

  yadm checkout -- ~/.emacs.d/private/

Set up dotfiles

Update our dotfiles remotes

This line in the bootstrap script will test if the current user is using my username. If yes, its probably me.

  if ! test (echo "phundrak" | sed -e "s/^.*$USER//I")

If it is me installing and using these dotfiles, I want the remotes of my dotfiles to be set to ssh remotes using my ssh keys.

  printf "\n# Update yadms remotes #######################################################\n\n"
  yadm remote set-url origin git@labs.phundrak.fr:phundrak/dotfiles.git
  yadm remote add github git@github.com:phundrak/dotfiles.git

I will also want to decrypt my encrypted files, such as said ssh keys.

  printf "\n# Decrypt encrypted dotfiles ##################################################\n\n"
  yadm decrypt

Finally, lets close this if statement.

  end
Get envtpl

Before we set our dotfiles up, lets make sure envtpl is correctly installed. This package will be needed for generating our alt dotfiles.

  printf '\n# Install envtpl ##############################################################\n\n'
  yay -Syu python-envtpl-git
Update our submodules

Now we can download the various dependencies of our dotfiles. To do so, lets run the following command:

  printf "\n# Getting yadm susbmodules ####################################################\n\n"
  yadm submodule update --init --recursive
Generate our alt files

Now this should be the last manipulation on our dotfiles: lets create our alternate files:

  printf "\n# Generating alt files ########################################################\n\n"
  yadm alt
Symlink some system config files

We have some files in etc/ that are to be symlinked to /etc.

  for f in (find ~/.etc -type f)
      set dest (echo $f | sed -n 's/^.*etc\(.*\)$/\/etc\1/p')
      sudo ln -s $f $dest
  end

We may also want to symlink our nanorc to the /root directory for when we use nano as sudo.

  read --prompt "echo 'Symlink .nanorc to roots .nanorc? (Y/n): ' " -l nanoroot
  if test $nanoroot = 'y' || test $nanoroot = "Y" || test $nanoroot = ''
      printf "\n# Symlinking .nanorc to roots .nanorc ########################################\n\n"
      sudo ln -s $HOME/.nanorc /root/.nanorc
  end

Install basic packages

Lets set in a custom varible what packages well be needing.

  set PACKAGES \
  acpilight asar ascii aspell-en aspell-fr assimp awesome-terminal-fonts \
  base-devel bat biber bleachbit bluez-firmware bluez-utils bookworm boost bzip2 \
  chromium clisp compton cppcheck cppreference cppreference-devhelp cpupower \
  cronie cryptsetup device-mapper diffutils discord-canary discount ditaa dmenu \
  dmenu-lpass docker docker-compose doxygen dunst dwarffortress emacs \
  exfat-utils farbfel ffmpegthumbnailer findutils firefox flake8 \
  font-mathematica fontforge freeglut fzf gcc-libs gdb gimp glibc \
  gnome-disk-utility gnome-epub-thumbnailer gnu-free-fonts gnuplot go-tools \
  graphviz htop i3-gaps i3lock-blur i3status igdm-bin inetutils j4-dmenu-desktop \
  jfsutils jmtpfs lastpass-cli less linux-headers lldb logrotate lvm2 ly-git \
  meson minted mpc mpd mpd-rich-presence-discord-git mpv mupdf-tools nano ncdu \
  ncmpcpp nemo-fileroller nemo-preview neofetch neovim netctl networkmanager \
  networkmanager-openvpn nm-connection-editor nnn nomacs noto-fonts-emoji npm \
  ntfs-3g numlockx openssh p7zip pacman-contrib pandoc-bin pavucontrol pciutils \
  pcurses pdfpc polybar pulseaudio-bluetooth python-envtpl-git python-pip \
  python-pywal qemu r raw-thumbnailer reflector rofi rofi-wifi-menu-git rsync \
  rtv rustup s-nail samba scrot sent shadow siji-git simplescreenrecorder \
  speedcrunch sshfs st-luke-git swi-prolog texlive-most texlive-bin \
  texlive-langchinese texlive-langcyrillic texlive-langgreek \
  texlive-langjapanese texlive-langkorean texlive-latexextra \
  texlive-localmanager-git tmux tree ttf-arphic-uming ttf-baekmuk \
  ttf-bitstream-vera ttf-dejavu ttf-google-fonts-opinionated-git ttf-joypixels \
  ttf-liberation ttf-material-design-icons-git ttf-ms-fonts ttf-symbola \
  ttf-tibetan-machine ttf-twemoji-color ttf-unifont unicode unicode-emoji unrar \
  usbutils valgrind w3m wget x11-ssh-askpass xclip xdg-user-dirs-gtk \
  xdotool xorg-drivers xorg-apps xfsprogs xorg-server xorg-xinit xss-lock yapf

These are the minimum I would have in my own installation. You can edit it however you want. Lets install those.

  printf "\n# Installing needed packages ##################################################\n\n"
  yay -S --needed $PACKAGES

Installing Tryones Compton fork

For some reason, I found installing directly this fork does not work, and I need to install it after I installed the regular compton packages. compton-tryone-git will replace compton which will be removed.

  printf "\n# Installing tryones compton fork ############################################\n\n"
  yay -S compton-tryone-git

Enable some of our services

We have installed some packages which require some services to run. Lets enable them.

Docker

First, lets activate Docker.

  printf "\n# Enabling and starting Docker ################################################\n\n"
  sudo systemctl enable --now docker

Now, if we wish it, we can be added to the docker group so we wont have to type sudo each time we call Docker or Docker Compose.

  read --prompt "echo 'Do you wish to be added to the `docker` group? (Y/n): ' " -l adddockergroup
  if test $adddockergroup = 'y' || test $adddockergroup = "Y" || test $adddockergroup = ''
      sudo usermod -aG docker $USER
  end
Emacs

Emacs will run as a user service, which means it wont be launched until we log in.

  printf "\n# Enabling Emacs as user service ##############################################\n\n"
  systemctl --user enable --now emacs
SSH server

Maybe we want to activate an SSH server on our machine. If so, we can enable it. Lets ask the question.

  read --prompt "echo 'Do you want to activate the ssh server? (Y/n): ' " -l sshdserver
  if test $sshdserver = 'y' || test $sshdserver = "Y" || test $sshdserver = ''
      printf "\n# Enabling ssh server #########################################################\n\n"
      sudo systemctl enable --now sshd
  end
Ly

Ly is a display manager based on ncurses which I find nice enough for me to use (I generally dont like using display managers). Lets enable it, and lets disable tty2 while were at it (Ly uses it to run X).

  sudo systemctl enable --now ly
  sudo systemctl disable getty@tty2
Acpilight

acpilight is our utility managing the brightness of our screen. There is actually no service to enable here, but we must ensure the user is part of the video group so we can modify the brightness of our screen without using sudo.

  sudo usermod -aG video $USER

Set up our fish shell

Install fisher

We will be using fisher as our extensions manager for Fish. Lets install it.

  printf "\n# Installing fisher ###########################################################\n\n"
  curl https://git.io/fisher --create-dirs -sLo ~/.config/fish/functions/fisher.fish
Install our extensions

I generally use the following extensions in my Fish shell.

  set FISHEXTENSIONS \
  edc/bass franciscolourenco/done jethrokuan/fzf jethrokuan/z \
  jorgebucaran/fish-getopts laughedelic/pisces matchai/spacefish \
  tuvistavie/fish-ssh-agent

Lets install these:

  fisher add $FISHEXTENSIONS

Install packages from git

Now, lets install some packages from git directly.

i3-gaps rounded

I know we already installed i3-gaps from the AUR, why reinstall it? Well, that is certainly bad practices, but this allowed me to already have the needed dependencies for building i3 installed. Now, lets clone it, build it, and install it. Doing this is probably very bad practices though, be warned.

  printf "\n# Install i3-gaps-rounded #####################################################\n\n"
  cd ~/fromGIT
  git clone https://github.com/resloved/i3.git i3-gaps-rounded
  cd i3-gaps-rounded
  rm -rf build
  autoreconf --force --install
  mkdir build && cd build
  ../configure --prefix=/usr --sysconfdir=/etc --disable-sanitizers
  make -j
  sudo make install
Polybar Battery

Now lets install polybar-battery. This is a binary that Ill use in my i3 config to indicate my battery level. It also sends a notification on low battery and on charging completed.

  printf "\n# Install polybar-battery #####################################################\n\n"
  cd ~/fromGIT
  git clone https://github.com/drdeimos/polybar_another_battery.git
  cd polybar_another_battery
  go get -u github.com/distatus/battery/cmd/battery
  make build

Now, we have our binary, lets symlink it in our local binary directory, ~/.local/bin.

  ln -s polybar-ab ~/.local/bin/polybar-ab
Reveal.JS

I sometimes use Reveal.JS to make presentations, and I set its location in my dotspacemacs file to be in ~/fromGIT, so lets clone it there.

  printf "\n# Install Reveal.JS ###########################################################\n\n"
  cd ~/fromGIT
  git clone https://github.com/hakimel/reveal.js.git

Install Rust

Install the toolchains

When using rust, I bounce between two toolchains, the stable toolchain and the nightly toolchain. To install them, I will use rustup which has already been installed.

  printf "\n# Install the rust toolchains, nightly is the default one #####################\n\n"
  rustup default nightly

This will both download the nightly toolchain and set it as the default one. Yup, I like to live dangerously. Now to install the stable toolchain, lets run this:

  rustup toolchain install stable
Install some utilities

Well need some utilities when developing Rust from Emacs, namely rustfmt and racer. Lets install them with cargo.

  printf "\n# Add rust utilities ##########################################################\n\n"
  cargo install rustfmt racer

Clean the pacman and yay cache

Finally, we are almost done! Lets clean the cache of pacman and yay.

  printf "\n# Clean the pacman and yay cache ##############################################\n\n"
  yay -Sc --noconfirm

You should now run a system pretty close to the one I have on my main computer and my thinkpad.

Licence

All of my dotfiles (and my dotfiles only) are available under the GNU GPLv3 Licence. Please consult /phundrak/dotfiles/src/commit/f1d40e2b1c542c6117c85a40c202a2398c283e5e/LICENCE.md for more information. In short: you are free to access, edit and redistribute all of my dotfiles under the same licence and as allowed by the licence, and if you fuck up something, its your own responsibility.