refactor(zsh): move configuration files
This commit is contained in:
parent
b7518872ff
commit
b58302c1ee
21 changed files with 17 additions and 7 deletions
23
roles/zsh/files/config/.zshrc
Normal file
23
roles/zsh/files/config/.zshrc
Normal file
|
@ -0,0 +1,23 @@
|
|||
sources=(
|
||||
'aliases'
|
||||
'colour'
|
||||
'functions'
|
||||
'fzf'
|
||||
'general'
|
||||
'git'
|
||||
'history'
|
||||
'navigation'
|
||||
'nvm'
|
||||
'options'
|
||||
'path'
|
||||
'platformsh'
|
||||
'plugins'
|
||||
'prompt'
|
||||
'post/completion'
|
||||
)
|
||||
for s in "${sources[@]}"; do
|
||||
source $ZDOTDIR/configs/${s}.zsh
|
||||
done
|
||||
|
||||
# Local config
|
||||
[[ -f ~/.zshrc.local ]] && source ~/.zshrc.local
|
3
roles/zsh/files/config/completion-scripts/_g
Normal file
3
roles/zsh/files/config/completion-scripts/_g
Normal file
|
@ -0,0 +1,3 @@
|
|||
#compdef g
|
||||
compdef g=git
|
||||
|
2
roles/zsh/files/config/completion-scripts/_m
Normal file
2
roles/zsh/files/config/completion-scripts/_m
Normal file
|
@ -0,0 +1,2 @@
|
|||
#compdef m
|
||||
compdef m=make
|
12
roles/zsh/files/config/configs/aliases.zsh
Normal file
12
roles/zsh/files/config/configs/aliases.zsh
Normal file
|
@ -0,0 +1,12 @@
|
|||
alias hosts='sudo vim /etc/hosts'
|
||||
alias rebase='git fetch --all --prune --prune-tags && git rebase'
|
||||
alias run='./run'
|
||||
alias sshconfig='vim ~/.ssh/config'
|
||||
alias vim='nvim'
|
||||
|
||||
# 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"
|
4
roles/zsh/files/config/configs/colour.zsh
Normal file
4
roles/zsh/files/config/configs/colour.zsh
Normal file
|
@ -0,0 +1,4 @@
|
|||
autoload -U colors
|
||||
colors
|
||||
|
||||
export CLICOLOR=1
|
38
roles/zsh/files/config/configs/functions.zsh
Normal file
38
roles/zsh/files/config/configs/functions.zsh
Normal file
|
@ -0,0 +1,38 @@
|
|||
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 $*
|
||||
}
|
||||
|
||||
nv() {
|
||||
if [[ $# > 0 ]];
|
||||
then
|
||||
nvim $@
|
||||
else
|
||||
nvim .
|
||||
fi
|
||||
}
|
2
roles/zsh/files/config/configs/fzf.zsh
Normal file
2
roles/zsh/files/config/configs/fzf.zsh
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Include keybindings for fzf.
|
||||
. /usr/share/doc/fzf/examples/key-bindings.zsh
|
5
roles/zsh/files/config/configs/general.zsh
Normal file
5
roles/zsh/files/config/configs/general.zsh
Normal file
|
@ -0,0 +1,5 @@
|
|||
precmd() {
|
||||
# Add a blank line before each command.
|
||||
print ''
|
||||
}
|
||||
|
10
roles/zsh/files/config/configs/git.zsh
Normal file
10
roles/zsh/files/config/configs/git.zsh
Normal 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
|
||||
}
|
7
roles/zsh/files/config/configs/history.zsh
Normal file
7
roles/zsh/files/config/configs/history.zsh
Normal file
|
@ -0,0 +1,7 @@
|
|||
setopt histignoredups
|
||||
|
||||
setopt inc_append_history
|
||||
|
||||
HISTSIZE=10000
|
||||
SAVEHIST=10000
|
||||
HISTFILE=~/.cache/zsh/history
|
9
roles/zsh/files/config/configs/navigation.zsh
Normal file
9
roles/zsh/files/config/configs/navigation.zsh
Normal file
|
@ -0,0 +1,9 @@
|
|||
bindkey -s "^f" "tmux-sessioniser\n"
|
||||
|
||||
# Search through history with the up and down arrows.
|
||||
autoload -U up-line-or-beginning-search
|
||||
autoload -U down-line-or-beginning-search
|
||||
zle -N up-line-or-beginning-search
|
||||
zle -N down-line-or-beginning-search
|
||||
bindkey "${terminfo[kcuu1]}" up-line-or-beginning-search # Up
|
||||
bindkey "${terminfo[kcud1]}" up-line-or-beginning-search # Down
|
2
roles/zsh/files/config/configs/nvm.zsh
Normal file
2
roles/zsh/files/config/configs/nvm.zsh
Normal 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"
|
3
roles/zsh/files/config/configs/options.zsh
Normal file
3
roles/zsh/files/config/configs/options.zsh
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Fix "zsh: no matches found: HEAD^" error.
|
||||
# See https://github.com/opdavies/dotfiles/issues/14.
|
||||
setopt NO_NOMATCH
|
23
roles/zsh/files/config/configs/path.zsh
Normal file
23
roles/zsh/files/config/configs/path.zsh
Normal file
|
@ -0,0 +1,23 @@
|
|||
setopt auto_cd
|
||||
|
||||
export PATH=\
|
||||
$PATH:\
|
||||
/usr/bin:\
|
||||
$HOME/.cargo/bin:\
|
||||
$HOME/.composer/vendor/bin:\
|
||||
$HOME/.dotfiles/bin:\
|
||||
$HOME/.dotfiles/bin/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
|
6
roles/zsh/files/config/configs/platformsh.zsh
Normal file
6
roles/zsh/files/config/configs/platformsh.zsh
Normal 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
|
10
roles/zsh/files/config/configs/plugins.zsh
Normal file
10
roles/zsh/files/config/configs/plugins.zsh
Normal 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
|
BIN
roles/zsh/files/config/configs/plugins.zsh.zwc
Normal file
BIN
roles/zsh/files/config/configs/plugins.zsh.zwc
Normal file
Binary file not shown.
18
roles/zsh/files/config/configs/post/completion.zsh
Normal file
18
roles/zsh/files/config/configs/post/completion.zsh
Normal 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:|=*'
|
14
roles/zsh/files/config/configs/prompt.zsh
Normal file
14
roles/zsh/files/config/configs/prompt.zsh
Normal file
|
@ -0,0 +1,14 @@
|
|||
source /usr/lib/git-core/git-sh-prompt
|
||||
|
||||
setopt promptsubst
|
||||
|
||||
git_prompt() {
|
||||
local branch="$(git symbolic-ref HEAD 2> /dev/null | cut -d'/' -f3)"
|
||||
local branch_truncated="${branch:0:30}"
|
||||
if (( ${#branch} > ${#branch_truncated} )); then
|
||||
branch="${branch_truncated}..."
|
||||
fi
|
||||
|
||||
[ -n "${branch}" ] && echo " (${branch})"
|
||||
}
|
||||
export PS1="in %{$fg[blue]%}%~%{$fg[yellow]%}$(git_prompt)%{$reset_color%} %(?.$.%{$fg[red]%}$)%b "
|
Loading…
Add table
Add a link
Reference in a new issue