54
homedir/.config/zsh.d/modules/config
Normal file
54
homedir/.config/zsh.d/modules/config
Normal file
@@ -0,0 +1,54 @@
|
||||
# Basic zsh configuration
|
||||
# vim: ft=zsh
|
||||
|
||||
# Custom completion
|
||||
fpath=( /etc/zsh/completion $fpath )
|
||||
|
||||
# Completion
|
||||
setopt noautomenu nomenucomplete
|
||||
|
||||
# Interactive comments
|
||||
setopt interactive_comments
|
||||
|
||||
# Disable autocd
|
||||
unsetopt autocd
|
||||
|
||||
# Command completion
|
||||
autoload -U compinit
|
||||
compinit
|
||||
|
||||
# Complete dotfiles
|
||||
_comp_options+=( globdots )
|
||||
|
||||
# History
|
||||
setopt HIST_IGNORE_DUPS
|
||||
|
||||
HISTFILE=~/.zsh_history
|
||||
SAVEHIST=9001
|
||||
HISTSIZE=9001
|
||||
HISTCONTROL=erasedups
|
||||
HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S"
|
||||
|
||||
# Fix retarded things
|
||||
NULLCMD=true
|
||||
READNULLCMD=true
|
||||
|
||||
# Locale
|
||||
export LC_ALL='en_US.UTF-8'
|
||||
|
||||
# dotfiles config
|
||||
dotfiles_dir="$HOME/git/dotfiles"
|
||||
|
||||
# PATH
|
||||
set_misc_path "$HOME/ruby/bin" "$HOME/games/bin" "$HOME/.config/alternatives" "$HOME/.local/bin" "$HOME/bin" "$HOME/.gem/ruby/2.3.0/bin/"
|
||||
|
||||
# GPG
|
||||
GPG_TTY=$(tty)
|
||||
export GPG_TTY
|
||||
|
||||
# EDITOR
|
||||
EDITOR=vim
|
||||
export EDITOR
|
||||
|
||||
# jspass completion
|
||||
compdef _pass jspass
|
24
homedir/.config/zsh.d/modules/core
Normal file
24
homedir/.config/zsh.d/modules/core
Normal file
@@ -0,0 +1,24 @@
|
||||
# Functions common to other modules
|
||||
# vim: ft=zsh
|
||||
|
||||
# Run the supplied command and null all the output
|
||||
function nullexec {
|
||||
"$@" &>/dev/null
|
||||
}
|
||||
|
||||
# Compile all includes
|
||||
function newconf {
|
||||
for i in ~/.zshrc ~/.config/zsh.d/*; do
|
||||
if ! [[ $i =~ .+\.zwc ]]; then
|
||||
msg "Compiling $i..."
|
||||
zcompile $i
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# set PATH from misc_path
|
||||
function set_misc_path {
|
||||
for p in $@; do
|
||||
PATH="$p:$PATH"
|
||||
done
|
||||
}
|
14
homedir/.config/zsh.d/modules/dotfiles
Normal file
14
homedir/.config/zsh.d/modules/dotfiles
Normal file
@@ -0,0 +1,14 @@
|
||||
# Functions for manipulating my dotfiles repo
|
||||
# vim: ft=zsh
|
||||
|
||||
function dotfiles() {
|
||||
declare act=$1
|
||||
|
||||
case $act in
|
||||
pull|diff) git -C $dotfiles_dir $1;;
|
||||
push)
|
||||
git -C $dotfiles_dir commit -a
|
||||
git -C $dotfiles_dir push
|
||||
;;
|
||||
esac
|
||||
}
|
8
homedir/.config/zsh.d/modules/helpers
Normal file
8
homedir/.config/zsh.d/modules/helpers
Normal file
@@ -0,0 +1,8 @@
|
||||
# Helper functions
|
||||
|
||||
xcopy() { xclip -selection clipboard }
|
||||
xpaste() { xclip -selection clipboard -o }
|
||||
|
||||
xclip() {
|
||||
/usr/bin/xclip -selection clipboard "$@"
|
||||
}
|
28
homedir/.config/zsh.d/modules/keys
Normal file
28
homedir/.config/zsh.d/modules/keys
Normal file
@@ -0,0 +1,28 @@
|
||||
# Keys
|
||||
# vim: ft=zsh
|
||||
|
||||
bindkey -e
|
||||
|
||||
declare -A key
|
||||
key[Home]=$terminfo[khome]
|
||||
key[End]=$terminfo[kend]
|
||||
key[Delete]=$terminfo[kdch1]
|
||||
|
||||
declare -A bindings
|
||||
bindings=(
|
||||
Home 'beginning-of-line'
|
||||
End 'end-of-line'
|
||||
Delete 'delete-char'
|
||||
^R 'history-incremental-search-backward'
|
||||
)
|
||||
|
||||
for b in ${(k)bindings}; do
|
||||
if [[ $key[$b] ]]; then
|
||||
bindkey $key[$b] $bindings[$b]
|
||||
fi
|
||||
done
|
||||
|
||||
function zle-line-init () { echoti smkx; }
|
||||
function zle-line-finish () { echoti rmkx; }
|
||||
zle -N zle-line-init
|
||||
zle -N zle-line-finish
|
8
homedir/.config/zsh.d/modules/local
Normal file
8
homedir/.config/zsh.d/modules/local
Normal file
@@ -0,0 +1,8 @@
|
||||
# Local zsh config, not to be synced.
|
||||
# vim: ft=zsh
|
||||
|
||||
# SSH
|
||||
SSH_AUTH_SOCK="/tmp/${USER}-ssh-auth.sock"
|
||||
export SSH_AUTH_SOCK
|
||||
|
||||
function x { exec xinit -- -nolisten tcp vt9; }
|
128
homedir/.config/zsh.d/modules/prompt
Normal file
128
homedir/.config/zsh.d/modules/prompt
Normal file
@@ -0,0 +1,128 @@
|
||||
# Prompt
|
||||
# vim: ft=zsh
|
||||
autoload -U colors && colors
|
||||
|
||||
nullexec() { "$@" &>/dev/null; }
|
||||
|
||||
precmd.title() {
|
||||
printf '%b' "\e]2;$1\a"
|
||||
}
|
||||
|
||||
precmd.svn() {
|
||||
if [[ -f .novcsprompt ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if nullexec svn info; then
|
||||
while IFS= read -r line; do
|
||||
case $line in
|
||||
(M*|A*|D*) svn_unstaged=1;;
|
||||
(\!*) svn_missing=1;;
|
||||
(\?*) svn_untracked=1;;
|
||||
esac
|
||||
done < <( svn st )
|
||||
|
||||
(( svn_unstaged )) && {
|
||||
svn_st+='c'
|
||||
svn_st_col='red'
|
||||
}
|
||||
|
||||
(( svn_missing )) && {
|
||||
svn_st+='m'
|
||||
svn_st_col='red'
|
||||
}
|
||||
|
||||
(( svn_untracked )) && {
|
||||
svn_st+='f'
|
||||
svn_st_col='red'
|
||||
}
|
||||
|
||||
svn_st_col=${svn_st_col:-"green"}
|
||||
svn_st=${svn_st:-"ok"}
|
||||
|
||||
printf '%s' "(%F{cyan}svn%f:%F{$svn_st_col}$svn_st%f) "
|
||||
fi
|
||||
}
|
||||
|
||||
precmd.git() {
|
||||
declare git_unstaged git_untracked git_status_short git_status_colour git_prompt_msg
|
||||
|
||||
if [[ -f .novcsprompt ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if git rev-parse --git-dir &>/dev/null; then
|
||||
git_current_branch=$(git rev-parse --abbrev-ref HEAD)
|
||||
|
||||
while IFS= read -r line; do
|
||||
case $line in
|
||||
' M'*|A*|D*) git_unstaged=1;;
|
||||
\?\?*) git_untracked=1;;
|
||||
esac
|
||||
done < <( git status --short )
|
||||
|
||||
(( git_unstaged )) && {
|
||||
git_status_short+='c'
|
||||
git_status_colour='red'
|
||||
}
|
||||
|
||||
(( git_untracked )) && {
|
||||
git_status_short+='f'
|
||||
git_status_colour='red'
|
||||
}
|
||||
|
||||
git_status_short=${git_status_short:-"ok"}
|
||||
git_status_colour=${git_status_colour:-"green"}
|
||||
|
||||
git_prompt_msg="(%F{cyan}$git_current_branch%f[%F{$git_status_colour}${git_status_short}%f]) "
|
||||
|
||||
printf '%s' $git_prompt_msg
|
||||
fi
|
||||
}
|
||||
|
||||
rprompt() {
|
||||
{ precmd.svn; precmd.git } > "$XDG_RUNTIME_DIR/zsh_rprompt_$$.tmp"
|
||||
kill -s USR1 $$
|
||||
}
|
||||
|
||||
TRAPUSR1() {
|
||||
prompt_async_data=$(<"$XDG_RUNTIME_DIR/zsh_rprompt_$$.tmp")
|
||||
draw_prompt
|
||||
zle && zle reset-prompt
|
||||
}
|
||||
|
||||
draw_prompt() {
|
||||
prompt_custom=(
|
||||
"%F{$cmd_colour}$cmd_msg%f"
|
||||
"%F{$user_colour}$USER%f@$HOST"
|
||||
"${PWD//$HOME/~}"
|
||||
"$prompt_async_data%F{$user_colour}>%f"
|
||||
)
|
||||
|
||||
PROMPT=" $prompt_custom "
|
||||
}
|
||||
|
||||
precmd() {
|
||||
declare last_exit_code=$?
|
||||
declare -g cmd_colour cmd_msg
|
||||
|
||||
if (( last_exit_code )); then
|
||||
cmd_colour='red'
|
||||
cmd_msg='!'
|
||||
else
|
||||
cmd_colour='green'
|
||||
cmd_msg='.'
|
||||
fi
|
||||
|
||||
if (( UID )); then
|
||||
user_colour='green'
|
||||
else
|
||||
user_colour='red'
|
||||
fi
|
||||
|
||||
precmd.title "$USER@$HOST ${PWD//$HOME/~}"
|
||||
|
||||
draw_prompt
|
||||
|
||||
rprompt &!
|
||||
}
|
7
homedir/.config/zsh.d/modules/shell
Normal file
7
homedir/.config/zsh.d/modules/shell
Normal file
@@ -0,0 +1,7 @@
|
||||
# Functions meant to be used interactively.
|
||||
# vim: ft=zsh
|
||||
|
||||
# Source the .zshrc again
|
||||
function reload {
|
||||
exec zsh -i
|
||||
}
|
6
homedir/.config/zsh.d/modules/xdg
Normal file
6
homedir/.config/zsh.d/modules/xdg
Normal file
@@ -0,0 +1,6 @@
|
||||
# http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
||||
export XDG_DATA_HOME=$HOME/.local/share
|
||||
export XDG_CACHE_HOME=$HOME/.cache
|
||||
export XDG_RUNTIME_DIR=/run/user/$UID
|
||||
export XDG_CONFIG_HOME=$HOME/.config
|
||||
|
Reference in New Issue
Block a user