Use stow for managing dotfiles

This commit is contained in:
Oliver Davies 2021-07-10 22:20:50 +01:00
parent 7b29ee2104
commit 7fed1cf922
83 changed files with 61 additions and 40 deletions

View file

@ -0,0 +1,3 @@
#compdef g
compdef g=git

View file

@ -0,0 +1,2 @@
#compdef m
compdef m=make

View file

@ -0,0 +1,32 @@
alias c="clear"
alias l="ls -lah"
# Open the current directory in Finder.
alias o="open ."
alias hosts="sudo vim /etc/hosts"
alias sshconfig='vim ~/.ssh/config'
# Pretty print the path.
alias path='echo $PATH | tr -s ":" "\n"'
# Open the current directory in PhpStorm.
# Open the current directory in Sublime Text.
alias sublime='open -a /Applications/Sublime\ Text.app "`pwd`"'
# Allow for pasting lines of code that start with a dollar sign.
alias \$=''
# Re-implement pbcopy and pbpaste from macOS.
alias pbcopy="xclip -selection clipboard"
alias pbpaste="xclip -selection clipboard -o"
# Include custom aliases
if [[ -f ~/.aliases.local ]]; then
source ~/.aliases.local
fi
# Open directory aliases
if [[ -f $(pwd)/.aliases ]]; then
source $(pwd)/.aliases
fi

View file

@ -0,0 +1,4 @@
autoload -U colors
colors
export CLICOLOR=1

View file

@ -0,0 +1,29 @@
function m() {
if [[ -f .notes/Makefile ]];
then
make -f .notes/Makefile "$@"
else
make "$@"
fi
}
function mkd() {
mkdir -p "$@" && cd "$@"
}
function composer() {
docker run -u $UID -it --rm \
-v $(pwd):/app \
-v ~/.composer:/root/.composer \
-v ~/.ssh:/root/.ssh \
composer \
composer $*
}
# Run 'phpunit' or 'pest' depending on the project.
function p () {
vendor/bin/$(phpunit-or-pest) $*;
}
function pf () {
vendor/bin/$(phpunit-or-pest) --filter $*
}

View file

@ -0,0 +1,5 @@
precmd() {
# Add a blank line before each command.
print ''
}

10
zsh/.zsh/configs/git.zsh Normal file
View file

@ -0,0 +1,10 @@
# No arguments: `git status`
# With arguments: acts like `git`
g() {
if [[ $# > 0 ]];
then
git $@
else
git status --short --branch
fi
}

View file

@ -0,0 +1,5 @@
setopt inc_append_history
HISTSIZE=10000
SAVEHIST=10000
HISTFILE=~/.cache/zsh/history

2
zsh/.zsh/configs/nvm.zsh Normal file
View file

@ -0,0 +1,2 @@
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

View file

@ -0,0 +1,3 @@
# Fix "zsh: no matches found: HEAD^" error.
# See https://github.com/opdavies/dotfiles/issues/14.
setopt NO_NOMATCH

20
zsh/.zsh/configs/path.zsh Normal file
View file

@ -0,0 +1,20 @@
setopt auto_cd
export PATH=\
$PATH:\
/usr/bin:\
$HOME/.composer/vendor/bin:\
$HOME/.local/bin:\
$HOME/.platformsh/bin:\
$HOME/bin:\
$HOME/snap/bin:\
bin:\
node_modules/.bin:\
vendor/bin
export CDPATH=\
./:\
$HOME/Code:\
$HOME/Code/clients:\
$HOME/Code/os:\
$HOME

View file

@ -0,0 +1,6 @@
# Platform.sh CLI configuration.
export PATH="$HOME/"'.platformsh/bin':"$PATH"
if [ -f "$HOME/"'.platformsh/shell-config.rc' ]; then
. "$HOME/"'.platformsh/shell-config.rc';
fi

View file

@ -0,0 +1,10 @@
# antigen.zsh has been downloaded manually for now,
# see https://github.com/zsh-users/antigen/issues/659.
source $HOME/.antigen.zsh
antigen bundle mollifier/cd-gitroot
antigen bundle zsh-users/zsh-autosuggestions
antigen bundle zsh-users/zsh-completions
antigen bundle zsh-users/zsh-syntax-highlighting
antigen apply

Binary file not shown.

View file

@ -0,0 +1,18 @@
# load our own completion functions
fpath=(~/.zsh/completion-scripts /usr/local/share/zsh/site-functions $fpath)
# completion; use cache if updated within 24h
autoload -Uz compinit
if [[ -n $HOME/.zcompdump(#qN.mh+24) ]]; then
compinit -d $HOME/.zcompdump;
else
compinit -C;
fi;
# disable zsh bundled function mtools command mcd
# which causes a conflict.
compdef -d mcd
## case-insensitive (all), partial-word and then substring completion
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' \
'r:|[._-]=* r:|=*' 'l:|=* r:|=*'

View file

@ -0,0 +1,45 @@
source /usr/lib/git-core/git-sh-prompt
git_is_repo() {
if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == "true" ]]; then
return 1
fi
return 0
}
git_current_branch() {
echo $(git rev-parse --abbrev-ref HEAD)
}
git_repo_is_dirty() {
if [[ -z $(git status --short) ]]; then
return 1;
fi
return 0;
}
git_prompt_info() {
! git_is_repo || return
current_branch=$(git_current_branch 2> /dev/null)
current_commit=$(git rev-parse --short HEAD 2> /dev/null)
suffix=''
if [[ ! -z ${current_commit} ]]; then
suffix="${suffix} [%{$fg_bold[yellow]%}${current_commit}%{$reset_color%}]"
fi
if git_repo_is_dirty; then
suffix="${suffix} %{$fg_bold[red]%}*%{$reset_color%}"
fi
if [[ -n git_current_branch ]]; then
echo " %{$fg_bold[green]%}$(__git_ps1 %s)%{$reset_color%}${suffix}"
fi
}
setopt promptsubst
export PS1='${SSH_CONNECTION+"%{$fg_bold[green]%}%n@%m:"}%{$fg_bold[blue]%}%~%{$reset_color%}$(git_prompt_info) \$ '

View file

@ -0,0 +1,7 @@
ensure_tmux_is_running() {
if _not_inside_tmux; then
tat
fi
}
ensure_tmux_is_running

4
zsh/.zshenv Normal file
View file

@ -0,0 +1,4 @@
PROMPT_EOL_MARK=''
ZLE_REMOVE_SUFFIX_CHARS=''

37
zsh/.zshrc Normal file
View file

@ -0,0 +1,37 @@
# Enable extended globbing for use in _load_settings()
setopt extendedglob
# extra files in ~/.zsh/configs/pre , ~/.zsh/configs , and ~/.zsh/configs/post
# these are loaded first, second, and third, respectively.
_load_settings() {
_dir="$1"
if [ -d "$_dir" ]; then
if [ -d "$_dir/pre" ]; then
for config in "$_dir"/pre/**/*~*.zwc(N-.); do
. $config
done
fi
for config in "$_dir"/**/*(N-.); do
case "$config" in
"$_dir"/(pre|post)/*|*.zwc)
:
;;
*)
. $config
;;
esac
done
if [ -d "$_dir/post" ]; then
for config in "$_dir"/post/**/*~*.zwc(N-.); do
. $config
done
fi
fi
}
_load_settings "$HOME/.zsh/configs"
# Local config
[[ -f ~/.zshrc.local ]] && source ~/.zshrc.local