Skip to content

juliusgarbe/dotfiles

Repository files navigation

Dotfiles

This repository contains my personal system configuration files, a.k.a. dotfiles.

Contents

  • .app-defaults/: Contains X applications default resources.
  • .bash/: Contains general shell environment definitions.
    • aliases.sh: Contains all personal bash alias definitions.
    • functions.sh: Contains all personal bash functions.
    • prompt.sh: Customize appearance of shell prompt.
    • variables.sh: Contains personal environment variables.
  • .bash_profile: General configuration file for the Bash login shell. Sets the preferred custom shell.
  • .bashrc: Configuration file for interactive non-login Bash shells. Loads aliases from .bash/aliases.sh, functions from .bash/functions.sh, and environment variables from .bash/variables.sh.
  • .cdo/: Settings for the Climate Data Operators (CDO).
  • .condarc: Configuration file for the Conda Python package management system.
  • .config/: Contains further user-specific configuration files.
  • .gitconfig: Git configuration file, contains some handy aliases and UI color definitions.
  • .jupyter/: Contains configuration files for Jupyter Notebooks.
    • .custom/custom.css: This file mainly adds custom UI colors and some font styles to Jupyter Notebooks.
  • .kshrc: Configuration file for the KornShell. Currently not used.
  • .launch-jupyter: Run Jupyter Notebooks on login nodes with output-forwarding into my local browser. Requires logging in with port listening enabled (ssh -L). Load automatically using ssh [...] -t 'exec bash ~/.launch-jupyter; bash -i'.
  • .launch-jupyter-slurm: Run Jupyter Notebooks on compute nodes (using SLURM) with output-forwarding into my local browser. Requires logging in with port listening enabled (ssh -L).
  • .ncmaps/: Contains ncmaps settings.
  • .ncviewrc: Configuration file for Ncview. I'm using ncmaps to bring in and manage my favorite scientific color maps.
  • .profile: General configuration file for the Bash login shell. Only sourced if no .bash_profile is present. Currently empty, but custom environment variables might be defined here.
  • .vimrc: Configuration file for Vim. I'm using vim-plug, e.g. for the Nord color scheme and a beautiful statusline.
  • .xinitrc: Configuration file for the initialization of the X Server. Not used.
  • .Xresources: Configuration file for the X Window System. I'm using the pretty Nord color theme. Also adds some UI customization for Ncview.
  • .zshrc: Configuration file for Oh My Zsh. Loads custom themes and plugins, as well as custom shell aliases, functions, environment variables, and more. The agnoster theme requires Powerline-patched Fonts to be installed and a unicode-compatible terminal (I use iTerm2) in order to render properly.

ZSH

Theme / prompt

ZSH is configured with the Agnoster theme which adds some more useful information to the prompt, e.g. it indicates the active conda environment as well as the current version control worktree status by changing its color:

Unstaged changes: prompt unstaged changes

Staged changes: prompt staged changes

Clean worktree: prompt clean worktree

For more capabilities of the Agnoster theme and tips how to customize the prompt view, see here.

Fuzzy Finder

I'm using FZF. It's great - see yourself!

fzf

FZF uses fd to find files and the preview is configured to use Bat for previewing files with syntax highlighting. I'm also using the Nord theme here. For directories, the contents are listed with ls.

Other OMZ plugins

Autosuggestions

Adds type-ahead autocomplete suggestions based on the command history and completions:

autosuggestions

Syntax highlighting

The zsh-syntax-highlighting plugin makes commands turn green if typed right, red if not, while files & folders get underlined if existing.

Vim

Plugins

My plugins are managed through the vim-plug plugin manager. Below are some of the plugins I enjoy using:

Nord Vim

I'm using the beautiful Nord Vim color theme.

Statusline

The vim-airline plugin enables a nice and customizable statusline at the bottom of each Vim window: screenshot vim

Fuzzy Finder

Integrates FZF as a Vim plugin.

Indent Guides

The useful vim-indent-guides plugin adds the functionality to visually display indent levels in Vim.

Gitgutter

The vim-gitgutter plugin shows a git diff in the sign column, i.e. which lines have been added, modified, or removed.

Netrw

I'm using Vim's built-in file explorer (:Explore) for quick access to my files. It's simple yet helpful and with some customization it renders any additional plugin like NERDTree dispensable.

Mappings

I am a long-time Mac user and as such I'm used to certain shortcuts or key strokes when it comes to quick navigation between open files and windows. My Vim is therefore configured with key mappings like Shift/ to switch between vertical window splits, Alt/ to switch between open buffers, and Tab/ShiftTab to switch between tabs. Below are some more convenient key mappings I use:

Key Mapping Normal mode Insert mode
TabTab Open Fuzzy Finder ✔️
e Toggle Netrw browser side panel ✔️
F1 Toggle line numbers ✔️ ✔️
F2 Toggle paste mode ✔️ ✔️
F3 Toggle vim-gitgutter ✔️ ✔️
F4 Toggle invisible characters ✔️ ✔️
F5 Toggle spell checking ✔️ ✔️

Ncview

I use Ncview extensively, so I like it to look pretty. In addition to using the Nord color theme, I also made a few UI tweaks (see .Xresources) and I use ncmaps and cmasher to add some nice scientific color maps. Below are two examples using color maps from cmocean.

ncview_example1 ncview_example2

Git aliases

I also use some aliases to make Git look prettier and more convenient. If you want, for example, a much prettier looking git log, just add the following alias to the global Git config file (~/.gitconfig) by copy-pasting this command into your terminal:

git config --global alias.logg "log --color --graph --pretty=format:'%C(bold yellow)%h%C(reset) - %C(green)[%cr]%C(reset) %s - %C(dim white)%an%C(reset) %C(bold red)%d%C(reset)' --abbrev-commit"

Now, using the alias git logg instead of git log, your commit history looks like this: git logg

Similarly, you can output a formatted and colored list of the tags using the following alias:

git config --global alias.tags "tag --sort=taggerdate --format='%(color:bold yellow)%(refname:short)%(color:reset) - %(color:green)[%(taggerdate:relative)]%(color:reset) %(subject) - %(color:dim white)%(taggername)%(color:reset)'"

The output of git tags will now look like this:

git tags

Another shortcut to make the git branch command more informative is to define the following alias:

git config --global alias.branches "branch -vv"

Using git branches instead of the usual git branch now also prints the SHA1 and subject line of each branch's HEAD, as well as the name of the upstream branch:

git branches

Installing and managing dotfiles

⚠️ WARNING: These files contain code which affects the way your system behaves. DO NOT use blindly unless you know what that entails and only after reviewing the code. Use at your own risk! And always remember: with great power comes great responsibility. ☝️

Before installation, make sure to back up already existing configuration files in your $HOME folder if you care about them, so they won't be overwritten by Git. To install, use the following commands (note, that this dotfile repository should be managed as a bare Git repository):

git clone --bare https://github.com/juliusgarbe/dotfiles.git $HOME/.cfg
git --git-dir=$HOME/.cfg/ --work-tree=$HOME checkout

Create an alias config which is used instead of the regular git command when interacting with the configuration repository:

alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'

You might want to add the alias definition to your .bashrc (make sure to log out and log back in afterwards to be able to use it):

echo "alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'" >> $HOME/.bashrc

Set a local flag to hide files that are not explicitly tracked:

config config --local status.showUntrackedFiles no

After successful execution of the setup any file within the $HOME folder can be version-controlled with normal commands, replacing git with the newly created config alias, e.g.:

config status
config add .bashrc
config commit -m "Add bashrc"

For more details, see here.

Authorship

This repository is maintained by Julius Garbe. Unless stated otherwise, the code is licensed under the MIT License.