diff --git a/.bash_profile b/.bash_profile new file mode 100644 index 0000000..0c2fbc4 --- /dev/null +++ b/.bash_profile @@ -0,0 +1,11 @@ +# +# ~/.bash_profile +# + +if [ -d $XDG_CONFIG_HOME/shell/login.d ]; then + for file in $XDG_CONFIG_HOME/shell/login.d/*.sh; do + source $file + done +fi + +[[ -f ~/.bashrc ]] && . ~/.bashrc diff --git a/.bashrc b/.bashrc new file mode 100644 index 0000000..4f22ee4 --- /dev/null +++ b/.bashrc @@ -0,0 +1,23 @@ +# +# ~/.bashrc +# + +# If not running interactively, don't do anything +[[ $- != *i* ]] && return + +# Load files from rc.d +if [ -d $XDG_CONFIG_HOME/shell/rc.d ]; then + for file in $XDG_CONFIG_HOME/shell/rc.d/*.sh; do + source $file + done +fi + +# Load files from bashrc.d +if [ -d $XDG_CONFIG_HOME/shell/bashrc.d ]; then + for file in $XDG_CONFIG_HOME/shell/bashrc.d/*.bash; do + source $file + done +fi + +alias ls='ls --color=auto' +PS1='[\u@\h \W]\$ ' diff --git a/.config/shell/login.d/dotfilescripts.sh b/.config/shell/login.d/dotfilescripts.sh new file mode 100644 index 0000000..984b4c5 --- /dev/null +++ b/.config/shell/login.d/dotfilescripts.sh @@ -0,0 +1,2 @@ +# put personal scripts on the PATH to be callable +export PATH="$(du $XDG_CONFIG_HOME/scripts/bin | cut -f2 | tr '\n' ':')$PATH" diff --git a/.config/shell/login.d/go.sh b/.config/shell/login.d/go.sh new file mode 100644 index 0000000..2b54b7d --- /dev/null +++ b/.config/shell/login.d/go.sh @@ -0,0 +1,3 @@ +# //FIXME this needs to get the hell out of here -> put it in an env loading file +export GOPATH="$HOME/Code/go" +export PATH="$PATH:$GOPATH/bin" diff --git a/.profile b/.config/shell/login.d/xdg.sh similarity index 97% rename from .profile rename to .config/shell/login.d/xdg.sh index aaa87e5..9e5c596 100644 --- a/.profile +++ b/.config/shell/login.d/xdg.sh @@ -1,4 +1,3 @@ export XDG_CONFIG_HOME="$HOME/.config" export XDG_CACHE_HOME="$HOME/.cache" - export EDITOR=nvim diff --git a/.config/zsh/0-dotfiles-version-control-commands.zsh b/.config/shell/zshrc.d/0-dotfiles-version-control-commands.zsh similarity index 100% rename from .config/zsh/0-dotfiles-version-control-commands.zsh rename to .config/shell/zshrc.d/0-dotfiles-version-control-commands.zsh diff --git a/.config/zsh/0-history.zsh b/.config/shell/zshrc.d/0-history.zsh similarity index 100% rename from .config/zsh/0-history.zsh rename to .config/shell/zshrc.d/0-history.zsh diff --git a/.config/zsh/0-inline-glob-expansion.zsh b/.config/shell/zshrc.d/0-inline-glob-expansion.zsh similarity index 100% rename from .config/zsh/0-inline-glob-expansion.zsh rename to .config/shell/zshrc.d/0-inline-glob-expansion.zsh diff --git a/.config/zsh/0-screen-information-dialog.zsh b/.config/shell/zshrc.d/0-screen-information-dialog.zsh similarity index 100% rename from .config/zsh/0-screen-information-dialog.zsh rename to .config/shell/zshrc.d/0-screen-information-dialog.zsh diff --git a/.config/zsh/0-set-locale-to-us-utf8.zsh b/.config/shell/zshrc.d/0-set-locale-to-us-utf8.zsh similarity index 100% rename from .config/zsh/0-set-locale-to-us-utf8.zsh rename to .config/shell/zshrc.d/0-set-locale-to-us-utf8.zsh diff --git a/.config/zsh/1-enable-command-spelling-correction.zsh b/.config/shell/zshrc.d/1-enable-command-spelling-correction.zsh similarity index 100% rename from .config/zsh/1-enable-command-spelling-correction.zsh rename to .config/shell/zshrc.d/1-enable-command-spelling-correction.zsh diff --git a/.config/zsh/1-report-time-for-long-running-processes.zsh b/.config/shell/zshrc.d/1-report-time-for-long-running-processes.zsh similarity index 100% rename from .config/zsh/1-report-time-for-long-running-processes.zsh rename to .config/shell/zshrc.d/1-report-time-for-long-running-processes.zsh diff --git a/.config/zsh/1-set-up-powerlevel9k-theming.zsh b/.config/shell/zshrc.d/1-set-up-powerlevel9k-theming.zsh similarity index 100% rename from .config/zsh/1-set-up-powerlevel9k-theming.zsh rename to .config/shell/zshrc.d/1-set-up-powerlevel9k-theming.zsh diff --git a/.config/zsh/1-ssh-agent-autoconfiguration.zsh b/.config/shell/zshrc.d/1-ssh-agent-autoconfiguration.zsh similarity index 100% rename from .config/zsh/1-ssh-agent-autoconfiguration.zsh rename to .config/shell/zshrc.d/1-ssh-agent-autoconfiguration.zsh diff --git a/.config/shell/zshrc.d/20-essential.zsh b/.config/shell/zshrc.d/20-essential.zsh new file mode 100644 index 0000000..9048ffa --- /dev/null +++ b/.config/shell/zshrc.d/20-essential.zsh @@ -0,0 +1,123 @@ +# Clone zgen if you haven't already +check_zgen_installation() { + if [[ -z "$ZGEN_PARENT_DIR" ]]; then + ZGEN_PARENT_DIR=${${XDG_CONFIG_HOME}:="$HOME/.config/"} + ZGEN_DIR="$ZGEN_PARENT_DIR/zgen" + fi + if [[ ! -f $ZGEN_DIR/zgen.zsh ]]; then + if [[ ! -d "$ZGEN_PARENT_DIR" ]]; then + mkdir -p "$ZGEN_PARENT_DIR" + fi + pushd $ZGEN_PARENT_DIR + git clone https://github.com/tarjoilija/zgen.git $ZGEN_DIR + popd + fi + source $ZGEN_DIR/zgen.zsh + unset ZGEN_PARENT_DIR +} + +load_plugins() { + ZGEN_LOADED=() + ZGEN_COMPLETIONS=() + + zgen oh-my-zsh + + # If you want to customize your plugin list, create a file named + # .zgen-local-plugins in your home directory. That file will be sourced + # during startup *instead* of running this load-starter-plugin-list function, + # so make sure to include everything from this function that you want to keep. + + # If zsh-syntax-highlighting is bundled after zsh-history-substring-search, + # they break, so get the order right. + zgen load zdharma/fast-syntax-highlighting + zgen load zsh-users/zsh-history-substring-search + + # Set keystrokes for substring searching + zmodload zsh/terminfo + bindkey "$terminfo[kcuu1]" history-substring-search-up + bindkey "$terminfo[kcud1]" history-substring-search-down + + # Automatically run zgen update and zgen selfupdate every 7 days. + zgen load unixorn/autoupdate-zgen + + # Warn you when you run a command that you've set an alias for without + # using the alias. + zgen load djui/alias-tips + + # Colorize the things if you have grc installed. Well, some of the + # things, anyway. + zgen load unixorn/warhol.plugin.zsh + + zgen load chrissicool/zsh-256color + + # Add Fish-like autosuggestions to your ZSH. + zgen load zsh-users/zsh-autosuggestions + + # k is a zsh script / plugin to make directory listings more readable, + # adding a bit of color and some git status information on files and + # directories. + zgen load supercrabtree/k + + # Bullet train prompt setup. + zgen load bhilburn/powerlevel9k powerlevel9k + + # automatically sources (known/whitelisted) .autoenv.zsh files + # as long as you're in the folder (and can optionally 'unsource' on leaving) + zgen load Tarrasch/zsh-autoenv + + # radically enhanced cd command, all sorts of options + zgen load b4b4r07/enhancd + + # set up nvm, the npm version manager + zgen load lukechilds/zsh-nvm + + # Add git helper scripts. + zgen load unixorn/git-extra-commands + + # Tom Limoncelli's tooling for storing private information (keys, etc) + # in a repository securely by encrypting them with gnupg. + zgen load StackExchange/blackbox + + # Load some oh-my-zsh plugins + zgen oh-my-zsh plugins/pip + zgen oh-my-zsh plugins/sudo + zgen oh-my-zsh plugins/aws + zgen oh-my-zsh plugins/chruby + zgen oh-my-zsh plugins/colored-man-pages + zgen oh-my-zsh plugins/git + zgen oh-my-zsh plugins/github + zgen oh-my-zsh plugins/python + zgen oh-my-zsh plugins/rsync + zgen oh-my-zsh plugins/screen + zgen oh-my-zsh plugins/vagrant + zgen oh-my-zsh plugins/autojump + zgen oh-my-zsh plugins/tmux + zgen oh-my-zsh plugins/tmuxinator + + # when in a directory with vagrant/docker files can use start, stop, up, down + zgen load Cloudstek/zsh-plugin-appup + + # Load more completion files for zsh from the zsh-lovers github repo. + zgen load zsh-users/zsh-completions src + + # Docker completion + zgen load srijanshetty/docker-zsh + + # Very cool plugin that generates zsh completion functions for commands + # if they have getopt-style help text. It doesn't generate them on the fly, + # you'll have to explicitly generate a completion, but it's still quite cool. + zgen load RobSis/zsh-completion-generator + + # Tab complete rakefile targets. + zgen load unixorn/rake-completion.zshplugin + + # Load me last + GENCOMPL_FPATH=$HOME/.zsh/complete + + zgen save +} + +check_zgen_installation +if ! zgen saved; then + load_plugins +fi diff --git a/.config/zsh/3-configure-autocompletion.zsh b/.config/shell/zshrc.d/3-configure-autocompletion.zsh similarity index 100% rename from .config/zsh/3-configure-autocompletion.zsh rename to .config/shell/zshrc.d/3-configure-autocompletion.zsh diff --git a/.config/zsh/3-disable-enhancd-dot-dot-behavior.zsh b/.config/shell/zshrc.d/3-disable-enhancd-dot-dot-behavior.zsh similarity index 100% rename from .config/zsh/3-disable-enhancd-dot-dot-behavior.zsh rename to .config/shell/zshrc.d/3-disable-enhancd-dot-dot-behavior.zsh diff --git a/.config/zsh/5-install-tmux-plugin-manager.zsh b/.config/shell/zshrc.d/5-install-tmux-plugin-manager.zsh similarity index 100% rename from .config/zsh/5-install-tmux-plugin-manager.zsh rename to .config/shell/zshrc.d/5-install-tmux-plugin-manager.zsh diff --git a/.config/zsh/6-base.zsh b/.config/shell/zshrc.d/6-base.zsh similarity index 100% rename from .config/zsh/6-base.zsh rename to .config/shell/zshrc.d/6-base.zsh diff --git a/.config/zsh/6-l-calls-k.zsh b/.config/shell/zshrc.d/6-l-calls-k.zsh similarity index 100% rename from .config/zsh/6-l-calls-k.zsh rename to .config/shell/zshrc.d/6-l-calls-k.zsh diff --git a/.config/zsh/6-mkcd.zsh b/.config/shell/zshrc.d/6-mkcd.zsh similarity index 100% rename from .config/zsh/6-mkcd.zsh rename to .config/shell/zshrc.d/6-mkcd.zsh diff --git a/.config/zsh/6-newest-files.zsh b/.config/shell/zshrc.d/6-newest-files.zsh similarity index 100% rename from .config/zsh/6-newest-files.zsh rename to .config/shell/zshrc.d/6-newest-files.zsh diff --git a/.config/zsh/6-nvim-to-vim-if-installed.zsh b/.config/shell/zshrc.d/6-nvim-to-vim-if-installed.zsh similarity index 100% rename from .config/zsh/6-nvim-to-vim-if-installed.zsh rename to .config/shell/zshrc.d/6-nvim-to-vim-if-installed.zsh diff --git a/.config/zsh/6-ssht-tmux-attaching.zsh b/.config/shell/zshrc.d/6-ssht-tmux-attaching.zsh similarity index 100% rename from .config/zsh/6-ssht-tmux-attaching.zsh rename to .config/shell/zshrc.d/6-ssht-tmux-attaching.zsh diff --git a/.config/zsh/9-deduplicate-path-variable.zsh b/.config/shell/zshrc.d/9-deduplicate-path-variable.zsh similarity index 100% rename from .config/zsh/9-deduplicate-path-variable.zsh rename to .config/shell/zshrc.d/9-deduplicate-path-variable.zsh diff --git a/.config/zsh/20-essential.zsh b/.config/zsh/20-essential.zsh deleted file mode 100644 index 0c30947..0000000 --- a/.config/zsh/20-essential.zsh +++ /dev/null @@ -1,54 +0,0 @@ -ZGEN_LOADED=() -ZGEN_COMPLETIONS=() - -zgen oh-my-zsh - -# If you want to customize your plugin list, create a file named -# .zgen-local-plugins in your home directory. That file will be sourced -# during startup *instead* of running this load-starter-plugin-list function, -# so make sure to include everything from this function that you want to keep. - -# If zsh-syntax-highlighting is bundled after zsh-history-substring-search, -# they break, so get the order right. -zgen load zdharma/fast-syntax-highlighting -zgen load zsh-users/zsh-history-substring-search - -# Set keystrokes for substring searching -zmodload zsh/terminfo -bindkey "$terminfo[kcuu1]" history-substring-search-up -bindkey "$terminfo[kcud1]" history-substring-search-down - -# Automatically run zgen update and zgen selfupdate every 7 days. -zgen load unixorn/autoupdate-zgen - -# Warn you when you run a command that you've set an alias for without -# using the alias. -zgen load djui/alias-tips - -# Colorize the things if you have grc installed. Well, some of the -# things, anyway. -zgen load unixorn/warhol.plugin.zsh - -zgen load chrissicool/zsh-256color - -# Add Fish-like autosuggestions to your ZSH. -zgen load zsh-users/zsh-autosuggestions - -# k is a zsh script / plugin to make directory listings more readable, -# adding a bit of color and some git status information on files and -# directories. -zgen load supercrabtree/k - -# Bullet train prompt setup. -zgen load bhilburn/powerlevel9k powerlevel9k - -# automatically sources (known/whitelisted) .autoenv.zsh files -# as long as you're in the folder (and can optionally 'unsource' on leaving) -zgen load Tarrasch/zsh-autoenv - -# radically enhanced cd command, all sorts of options -zgen load b4b4r07/enhancd - -# set up nvm, the npm version manager -zgen load lukechilds/zsh-nvm - diff --git a/.config/zsh/21-integrations.zsh b/.config/zsh/21-integrations.zsh deleted file mode 100644 index 4b2fb8c..0000000 --- a/.config/zsh/21-integrations.zsh +++ /dev/null @@ -1,31 +0,0 @@ -if [ $(uname -a | grep -ci Darwin) = 1 ]; then -# Load macOS-specific plugins -zgen oh-my-zsh plugins/brew -zgen oh-my-zsh plugins/osx -fi - -# Add git helper scripts. -zgen load unixorn/git-extra-commands - -# Tom Limoncelli's tooling for storing private information (keys, etc) -# in a repository securely by encrypting them with gnupg. -zgen load StackExchange/blackbox - -# Load some oh-my-zsh plugins -zgen oh-my-zsh plugins/pip -zgen oh-my-zsh plugins/sudo -zgen oh-my-zsh plugins/aws -zgen oh-my-zsh plugins/chruby -zgen oh-my-zsh plugins/colored-man-pages -zgen oh-my-zsh plugins/git -zgen oh-my-zsh plugins/github -zgen oh-my-zsh plugins/python -zgen oh-my-zsh plugins/rsync -zgen oh-my-zsh plugins/screen -zgen oh-my-zsh plugins/vagrant -zgen oh-my-zsh plugins/autojump -zgen oh-my-zsh plugins/tmux -zgen oh-my-zsh plugins/tmuxinator - -# when in a directory with vagrant/docker files can use start, stop, up, down -zgen load Cloudstek/zsh-plugin-appup \ No newline at end of file diff --git a/.config/zsh/22-autocompletions.zsh b/.config/zsh/22-autocompletions.zsh deleted file mode 100644 index bef9425..0000000 --- a/.config/zsh/22-autocompletions.zsh +++ /dev/null @@ -1,16 +0,0 @@ -# Load more completion files for zsh from the zsh-lovers github repo. -zgen load zsh-users/zsh-completions src - -# Docker completion -zgen load srijanshetty/docker-zsh - -# Very cool plugin that generates zsh completion functions for commands -# if they have getopt-style help text. It doesn't generate them on the fly, -# you'll have to explicitly generate a completion, but it's still quite cool. -zgen load RobSis/zsh-completion-generator - -# Tab complete rakefile targets. -zgen load unixorn/rake-completion.zshplugin - -# Load me last -GENCOMPL_FPATH=$HOME/.zsh/complete diff --git a/.zlogin b/.zlogin new file mode 100644 index 0000000..2ebb768 --- /dev/null +++ b/.zlogin @@ -0,0 +1,8 @@ +# .zlogin +# +# load all files from .config/shell/login.d +if [ -d $XDG_CONFIG_HOME/shell/login.d ]; then + for file in $XDG_CONFIG_HOME/shell/login.d/*.sh; do + source $file + done +fi diff --git a/.zshrc b/.zshrc index 3d8199a..98cadd8 100644 --- a/.zshrc +++ b/.zshrc @@ -1,162 +1,19 @@ #!/bin/zsh -### DEFAULT DIRECTORY STRUCTURE -# -# ~/ -# - .zshrc > Initial setup, should not need to be changed -# - .bashrc > Bash setup (empty for my dotfiles) -# - .Xresources > Initial Xresources setup, redirects to .config/.Xresources.d/ -# - .tmux > Tmux setup (would love to put this into .config/ ) -# - .config/ > all other (program) configuration should go in this dir -# --------- .zshrc.d/ > The actual zsh setup files, see their configuration below -# --------- .Xresources.d/ > The actual Xresources setup files -# --------- .zgen/ > The zsh plugin manager -# - .dotfiles/ > the version control of dotfiles -# -#### - autoload zmv -## Show debug information -# -# ZSH_SETUP_SHOW_DEBUG="true" -# Uncomment the above line to get debug information during the script setup. -print_dbg() { - if [ -z $ZSH_SETUP_SHOW_DEBUG ]; then - return - fi - printf $@ -} - -# Clone zgen if you haven't already -check_zgen_installation() { - if [[ -z "$ZGEN_PARENT_DIR" ]]; then - ZGEN_PARENT_DIR=${${XDG_CONFIG_HOME}:="$HOME/.config/"} - ZGEN_DIR="$ZGEN_PARENT_DIR/zgen" - fi - if [[ ! -f $ZGEN_DIR/zgen.zsh ]]; then - if [[ ! -d "$ZGEN_PARENT_DIR" ]]; then - mkdir -p "$ZGEN_PARENT_DIR" - fi - pushd $ZGEN_PARENT_DIR - git clone https://github.com/tarjoilija/zgen.git $ZGEN_DIR - popd - fi - source $ZGEN_DIR/zgen.zsh - unset ZGEN_PARENT_DIR -} - -load_config_files() { - if [ -n "$(/bin/ls $1)" ]; then - # load the files in number range provided - GLOB=(${1}/[${2}][0123456789-]*) - for dotfile in $GLOB; do - if [ -r "${dotfile}" ]; then - print_dbg "Loading $dotfile\n" - source "${dotfile}" - fi +if [ -d $XDG_CONFIG_HOME/shell/rc.d ]; then + for file in $XDG_CONFIG_HOME/shell/rc.d/*.sh; do + source $file done - unset GLOB - fi -} - -#### ZSHrc - Setting up the Shell -## -## Almost all actual setup is being done with the help of individual files -## in the .config/zsh directory. This file just loads them. They follow this order: -## -## 0 are bootstrapping the zsh environment, setting aliases and sane -## shell defaults which should need no further changes. -## 1 allow custom bootstrapping of things that need to be set before any -## zsh plugins are loaded (e.g., theme environment vars, etc) -## 2 are run *during* zgen setup and can include plugins to be loaded -## 3 script & plugin configurations without *external* dependencies (i.e. can run with -## only what the dotfiles supply) They are run after plugins are loaded and can be configured -## in whatever way you wish. If you change the plugin setup, you may need to reconfigure here. -## 5 commands *with* external script dependencies (e.g. python, mpv, etc.). Scripts should -## check for their dependencies before enabling their commands. It makes scripts more readable -## to begin with their depency in the name, i.e. '5-python-mpv-spawn-unique-player-with-umpv' -## 6 Aliasing. -## 7,8 No default behavior, use however you like. -## 9 anything which has to run at the very end -## -## The running order can further be specified by having a second number, which will then run through -## them in the numbered order. -## -## Most of them are documented, and they try to have sensible naming. -## If you want to supply your own directory of zsh config files you can do so -## by setting the ZSH_CONFIG_DIR environment variable. You can also drop -## configuration files into the config dir without any numbers prepended, they -## will be run after numbered ones (in a random order) if you uncomment the -## corresponding line below. - -# Set ZSH_CONFIG_DIR to default to ~/.config/zsh, or let user override -# Exit early if no configuration directory has been found -if [ ! -d ${ZSH_CONFIG_DIR:="${XDG_CONFIG_HOME:-$HOME/.config}/zsh"} ]; then - # If the user explicitly overrode the path give him an error - if [ ! $ZSH_CONFIG_DIR = "${XDG_CONFIG_HOME:-$HOME/.config/}/zsh" ]; then - printf "\$ZSH_CONFIG_DIR=$ZSH_CONFIG_DIR/ does not exist.\n" - fi - PS1="$HOME $ " - return fi -if [[ -f $HOME/.profile ]]; then - source $HOME/.profile +if [ -d $XDG_CONFIG_HOME/shell/zshrc.d ]; then + for file in $XDG_CONFIG_HOME/shell/zshrc.d/*.zsh; do + source $file + done fi -# //TODO: Prints error when -no- files are found -# Load bootstrap settings (00-19) before plugin initialization -print_dbg "Starting bootstrap (00-19)...\n" -load_config_files $ZSH_CONFIG_DIR 01 -# set up zgen - load external zsh plugins -# If you need to reload your plugins use 'zgen reset' and restart -# your shell -if [ -n "$(/bin/ls $ZSH_CONFIG_DIR/)" ]; then - print_dbg "Starting plugin system...\n" #//DEBUG - - check_zgen_installation - - if ! zgen saved; then - print_dbg "Applying plugins (20-29)...\n" - load_config_files $ZSH_CONFIG_DIR 2 - # Save it all to init script. - zgen save - else - print_dbg "Plugins already applied. If you want to re-apply run 'zgen reset' and open new terminal.\n" - fi -fi - -# Load additional settings (30-99) after plugin initialization -print_dbg "Setting up remaining scripts (30-99)\n" -load_config_files $ZSH_CONFIG_DIR 3456789 - -# Uncomment this section to enable execution of arbitrarily named config files -# if [ -n "$(/bin/ls $ZSH_CONFIG_DIR/)" ]; then -# GLOB=($ZSH_CONFIG_DIR/[:alpha:]*) -# for dotfile in $GLOB; do -# print_dbg "Alphabetic: $dotfile\n" #//DEBUG -# if [ -r "${dotfile}" ]; then -# source "${dotfile}" -# fi -# done -# unset GLOB -# fi - -# put personal scripts on the PATH to be callable -export PATH="$(du $XDG_CONFIG_HOME/scripts/bin | cut -f2 | tr '\n' ':')$PATH" - -unset ZSH_CONFIG_DIR -# unset ZGEN_DIR -- Needs to remain set for some plugins to function -unset ZGEN_PARENT_DIR -unset ZSH_SETUP_SHOW_DEBUG -unfunction print_dbg -unfunction load_config_files -unfunction check_zgen_installation - -# //FIXME this needs to get the hell out of here -> put it in an env loading file -export GOPATH="$HOME/Code/go" -export PATH="$PATH:$GOPATH/bin"