From f7a498dbb73763ad3b4575210fe66b3ec870063e Mon Sep 17 00:00:00 2001 From: Fernando Schauenburg Date: Sun, 3 Nov 2019 01:53:27 +0100 Subject: [PATCH] Use XDG Base Directory Specification SSH is an exception because there seems to be no good way of supporting XDG. Patience, I guess... --- dotfiles/.bash_profile | 2 -- dotfiles/{.bashrc => .config/bash/profile} | 16 +++++++++++++--- dotfiles/{.gitconfig => .config/git/config} | 4 ++-- dotfiles/{.gitignore => .config/git/ignore} | 0 dotfiles/{.minttyrc => .config/mintty/config} | 0 dotfiles/{.inputrc => .config/readline/inputrc} | 0 dotfiles/{.tmux.conf => .config/tmux/tmux.conf} | 0 dotfiles/{.vim => .config/vim}/autoload/plug.vim | 0 dotfiles/{.vim => .config/vim}/vimrc | 11 ++++++++--- 9 files changed, 23 insertions(+), 10 deletions(-) delete mode 100644 dotfiles/.bash_profile rename dotfiles/{.bashrc => .config/bash/profile} (96%) rename dotfiles/{.gitconfig => .config/git/config} (96%) rename dotfiles/{.gitignore => .config/git/ignore} (100%) rename dotfiles/{.minttyrc => .config/mintty/config} (100%) rename dotfiles/{.inputrc => .config/readline/inputrc} (100%) rename dotfiles/{.tmux.conf => .config/tmux/tmux.conf} (100%) rename dotfiles/{.vim => .config/vim}/autoload/plug.vim (100%) rename dotfiles/{.vim => .config/vim}/vimrc (96%) diff --git a/dotfiles/.bash_profile b/dotfiles/.bash_profile deleted file mode 100644 index d44146f..0000000 --- a/dotfiles/.bash_profile +++ /dev/null @@ -1,2 +0,0 @@ -[ -f ~/.bashrc ] && . ~/.bashrc - diff --git a/dotfiles/.bashrc b/dotfiles/.config/bash/profile similarity index 96% rename from dotfiles/.bashrc rename to dotfiles/.config/bash/profile index 1128862..c46bc98 100644 --- a/dotfiles/.bashrc +++ b/dotfiles/.config/bash/profile @@ -5,14 +5,22 @@ # Customize environment ############################################################################## +export XDG_CACHE_HOME="$HOME/.cache" +export XDG_CONFIG_HOME="$HOME/.config" +export XDG_DATA_HOME="$HOME/.local/share" + export EDITOR="vim" +export INPUTRC="$XDG_CONFIG_HOME/readline/inputrc" export LANG="en_US.UTF-8" export LANGUAGE="en_US" -export LC_CTYPE="en_US.UTF-8" export LC_ALL="en_US.UTF-8" +export LC_CTYPE="en_US.UTF-8" export LESS="-i -j.49 -M -R -z-2" -export LESSHISTFILE=/dev/null +export LESSHISTFILE="$XDG_CACHE_HOME/less/history" +export LESSHISTSIZE=1000 export PAGER=less +export VIMINIT='let $MYVIMRC="$XDG_CONFIG_HOME/vim/vimrc" | source $MYVIMRC' + # Find out where Homebrew performs installations. If Homebrew is not # installed (e.g. running on Linux), assume /usr/local for our @@ -74,7 +82,7 @@ HISTCONTROL=erasedups HISTFILESIZE= HISTSIZE= HISTTIMEFORMAT="[%F %T] " -HISTFILE=~/.bash_eternal_history +HISTFILE="$XDG_CACHE_HOME/bash/history" # shellcheck disable=SC2034 # these variable are meant for use in shell only { @@ -197,6 +205,8 @@ alias path='echo $PATH | tr -s ":" "\n"' alias mpath='echo $MANPATH | tr -s ":" "\n"' alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date' +alias tmux='tmux -f "$XDG_CONFIG_HOME/tmux/tmux.conf"' + # A few options to get public IP address on command line. The dig solution # below using the OpenDNS resolver doesn't work when connected to # ExpressVPN because all DNS requests are handled by the ExpressVPN DNS diff --git a/dotfiles/.gitconfig b/dotfiles/.config/git/config similarity index 96% rename from dotfiles/.gitconfig rename to dotfiles/.config/git/config index 495e279..7cfbb6f 100644 --- a/dotfiles/.gitconfig +++ b/dotfiles/.config/git/config @@ -45,7 +45,7 @@ sub = submodule [core] - excludesfile = ~/.gitignore + excludesfile = ~/.config/git/ignore editor = vim trustctime = false # http://www.git-tower.com/blog/make-git-rebase-safe-on-osx/ pager = less -F -X @@ -80,4 +80,4 @@ required = true [include] - path = ~/.gitconfig.local + path = ~/.config/git/config.local diff --git a/dotfiles/.gitignore b/dotfiles/.config/git/ignore similarity index 100% rename from dotfiles/.gitignore rename to dotfiles/.config/git/ignore diff --git a/dotfiles/.minttyrc b/dotfiles/.config/mintty/config similarity index 100% rename from dotfiles/.minttyrc rename to dotfiles/.config/mintty/config diff --git a/dotfiles/.inputrc b/dotfiles/.config/readline/inputrc similarity index 100% rename from dotfiles/.inputrc rename to dotfiles/.config/readline/inputrc diff --git a/dotfiles/.tmux.conf b/dotfiles/.config/tmux/tmux.conf similarity index 100% rename from dotfiles/.tmux.conf rename to dotfiles/.config/tmux/tmux.conf diff --git a/dotfiles/.vim/autoload/plug.vim b/dotfiles/.config/vim/autoload/plug.vim similarity index 100% rename from dotfiles/.vim/autoload/plug.vim rename to dotfiles/.config/vim/autoload/plug.vim diff --git a/dotfiles/.vim/vimrc b/dotfiles/.config/vim/vimrc similarity index 96% rename from dotfiles/.vim/vimrc rename to dotfiles/.config/vim/vimrc index 65db3c1..70c4e53 100644 --- a/dotfiles/.vim/vimrc +++ b/dotfiles/.config/vim/vimrc @@ -1,5 +1,7 @@ set nocompatible +let $MYVIMRC="$XDG_CONFIG_HOME/vim/vimrc" + " Options {{{ set autoindent set autoread @@ -30,6 +32,7 @@ set nocompatible set list set modelines=0 set number + set runtimepath=$XDG_CONFIG_HOME/vim,$VIMRUNTIME set scrolloff=5 set shiftwidth=4 set shortmess+=I @@ -56,7 +59,7 @@ set nocompatible " | | | | | | " v v v v v v set viminfo=h,'500,<10000,s1000,/1000,:1000 - set viminfofile=~/.vim/viminfo + set viminfofile=$XDG_CACHE_HOME/vim/viminfo set virtualedit=block set wildignore=*.o,*.obj,*.pyc,*.exe,*.so,*.dll set wildmenu @@ -75,7 +78,7 @@ set nocompatible " }}} " Plugins {{{ - call plug#begin('~/.vim/bundle') + call plug#begin('$XDG_CONFIG_HOME/vim/bundle') Plug 'altercation/vim-colors-solarized' Plug 'bronson/vim-trailing-whitespace' Plug 'elzr/vim-json' @@ -229,5 +232,7 @@ augroup vimrc " {{{ autocmd FileType gitcommit setlocal textwidth=72 augroup END " }}} -if filereadable(expand("~/.vimrc.local")) | source ~/.vimrc.local | endif +if filereadable(expand("$XDG_CONFIG_HOME/vimrc.local")) + source $XDG_CONFIG_HOME/vimrc.local +endif