initial commit

This commit is contained in:
Mark Riedesel 2019-07-19 14:24:59 -05:00
commit f443da5f31
9 changed files with 442 additions and 0 deletions

View file

@ -0,0 +1,103 @@
# Treat glob chars as literals when there are no matches (like bash)
setopt no_nomatch
## History
HISTFILE="$HOME/.zsh_history"
HISTSIZE=100000
SAVEHIST=100000
# Don't record consecutive duplicates or lines starting with a space
setopt hist_ignore_dups
setopt hist_ignore_space
setopt hist_save_no_dups
setopt hist_reduce_blanks
setopt hist_expire_dups_first
setopt share_history
# Append to the history file instead of over-writing it after each session
#setopt inc_append_history
# Enable Vim mode (press esc to start)
bindkey -e
# Fancy ctrl-z (thanks, Adam Stankiewicz!)
fancy-ctrl-z () {
if [[ $#BUFFER -eq 0 ]]; then
fg
zle redisplay
else
zle push-input
zle clear-screen
fi
}
zle -N fancy-ctrl-z
bindkey '^Z' fancy-ctrl-z
bindkey '^P' up-line-or-search
bindkey '^N' down-line-or-search
autoload -Uz colors && colors
setopt prompt_subst
fish_pwd() {
echo ${${:-/${(j:/:)${(M)${(s:/:)${(D)PWD:h}}#(|.)[^.]}}/${PWD:t}}//\/~/\~}
}
sorin_pwd() {
local current_pwd="${PWD/#$HOME/~}"
local ret_directory
if [[ "$current_pwd" == "~" ]]; then
ret_directory="~"
unset MATCH
else
ret_directory=${${:-${(j:/:)${(M)${(s:/:)${(D)PWD:h}}#(|.)[^.]}}/${PWD:t}}//\/~/\~}
fi
echo $ret_directory
}
## Prompts
PROMPT=''
if [[ ! -z "$SSH_CLIENT" ]] then
PROMPT+="%B%F{blue}%m%b%f "
fi
PROMPT+="%F{blue}"
PROMPT+='$(sorin_pwd)'
PROMPT+=" "
PROMPT+="%f%s%b "
# Get LS_COLORS
if [[ -z "${LS_COLORS}" ]] && [[ -x '/usr/bin/dircolors' ]]; then
eval "$( /usr/bin/dircolors -b )"
fi
## Completion Settings
######################
(( ${fpath[(I)/usr/share/zsh/site-functions]} )) ||
fpath+=( /usr/share/zsh/site-functions )
autoload -Uz compinit && compinit
zmodload zsh/complist
# Offer to correct mispelings
setopt correct
# Always display tags separately
zstyle ':completion:*' group-name ''
# Case-insensitive matching
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}'
# Show completing ____' in the menu thing
zstyle ':completion:*:descriptions' format $'%{\e[0;35m%}completing %B%d:%b%{\e[0m%}'
# Display a selection box around the completion menu items
zstyle ':completion:*' menu select=2
# Ignore users with /bin/false or /bin/nologin as their log-in shell
zstyle ':completion:*' users ${${${(f)"$( < /etc/passwd )"}:#*/(false|nologin)}%%:*}
# Define the order and display names of groups for `ssh`
zstyle ':completion:*:ssh:*' tag-order 'hosts:hosts:host users:users:user'
zstyle ':completion:*:ssh:*' group-order 'hosts users'

View file

@ -0,0 +1,2 @@
local _path=~/.cache/wal/sequences
[ -f $_path ] && (cat $_path)

View file

@ -0,0 +1,80 @@
typeset _agent_forwarding _ssh_env_cache
function _start_agent() {
local lifetime
zstyle -s :omz:plugins:ssh-agent lifetime lifetime
# start ssh-agent and setup environment
echo Starting ssh-agent...
ssh-agent -s ${lifetime:+-t} ${lifetime} | sed 's/^echo/#echo/' >! $_ssh_env_cache
chmod 600 $_ssh_env_cache
. $_ssh_env_cache > /dev/null
}
function _add_identities() {
local id line sig
local -a identities loaded_sigs loaded_ids not_loaded
zstyle -a :omz:plugins:ssh-agent identities identities
# check for .ssh folder presence
if [[ ! -d $HOME/.ssh ]]; then
return
fi
# add default keys if no identities were set up via zstyle
# this is to mimic the call to ssh-add with no identities
if [[ ${#identities} -eq 0 ]]; then
# key list found on `ssh-add` man page's DESCRIPTION section
for id in id_rsa id_dsa id_ecdsa id_ed25519 identity; do
# check if file exists
[[ -f "$HOME/.ssh/$id" ]] && identities+=$id
done
fi
# get list of loaded identities' signatures and filenames
for line in ${(f)"$(ssh-add -l)"}; do
loaded_sigs+=${${(z)line}[2]}
loaded_ids+=${${(z)line}[3]}
done
# add identities if not already loaded
for id in $identities; do
# check for filename match, otherwise try for signature match
if [[ ${loaded_ids[(I)$HOME/.ssh/$id]} -le 0 ]]; then
sig="$(ssh-keygen -lf "$HOME/.ssh/$id" | awk '{print $2}')"
[[ ${loaded_sigs[(I)$sig]} -le 0 ]] && not_loaded+="$HOME/.ssh/$id"
fi
done
[[ -n "$not_loaded" ]] && ssh-add ${^not_loaded}
}
# Get the filename to store/lookup the environment from
_ssh_env_cache="$HOME/.ssh/environment-$HOST"
# test if agent-forwarding is enabled
zstyle -b :omz:plugins:ssh-agent agent-forwarding _agent_forwarding
if [[ $_agent_forwarding == "yes" && -n "$SSH_AUTH_SOCK" ]]; then
# Add a nifty symlink for screen/tmux if agent forwarding
[[ -L $SSH_AUTH_SOCK ]] || ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USER-screen
elif [[ -f "$_ssh_env_cache" ]]; then
# Source SSH settings, if applicable
. $_ssh_env_cache > /dev/null
if [[ $USER == "root" ]]; then
FILTER="ax"
else
FILTER="x"
fi
ps $FILTER | grep ssh-agent | grep -q $SSH_AGENT_PID || {
_start_agent
}
else
_start_agent
fi
_add_identities
# tidy up after ourselves
unset _agent_forwarding _ssh_env_cache
unfunction _start_agent _add_identities

View file

@ -0,0 +1,38 @@
alias wallpaper="feh --bg-fill -z"
alias retheme="wal -q -t -i ~/wallpaper"
alias svim="sudo nvim"
alias capesc="setxkbmap -option caps:escape"
alias mapstylus='xinput --map-to-output $(xinput --list --id-only "ELAN2514:00 04F3:2594 Pen Pen (0)") eDP-1'
#alias rsync="noglob rsync"
alias tmux="TERM=xterm-256color tmux"
# Make `sudo` respect aliases
alias sudo='sudo '
# Enable colorized `ls`
if [[ -n "${ZSH_VERSION}" ]]; then
alias ls='ls -p --color=auto $=LS_OPTIONS'
elif [[ -n "${BASH_VERSION}" ]]; then
alias ls='ls -p --color=auto $LS_OPTIONS'
fi
# Alias dig to drill on boxes where I don't have dig but do have drill
if (( ! $+commands[dig] && $+commands[drill] )) then
alias dig='drill'
fi
# Handy `ls` aliases
alias ll='ls -alF'
alias la='ls -A'
# Enable grep color
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
# Default editor alias
alias edit='${EDITOR}:-vim}'
# Prefer neovim if available
if (( $+commands[nvim] )) then
alias vim='nvim'
fi

View file

@ -0,0 +1,7 @@
export LESS_TERMCAP_mb=$'\E[01;31m'
export LESS_TERMCAP_md=$'\E[01;38;5;74m'
export LESS_TERMCAP_me=$'\E[0m'
export LESS_TERMCAP_se=$'\E[0m'
export LESS_TERMCAP_so=$'\E[38;33;246m'
export LESS_TERMCAP_ue=$'\E[0m'
export LESS_TERMCAP_us=$'\E[04;38;5;146m'

View file

@ -0,0 +1,77 @@
GIT_PROMPT_PREFIX=""
GIT_PROMPT_SUFFIX="%f%k"
GIT_PROMPT_AHEAD="%F{yellow}NUM⬆%f"
GIT_PROMPT_BEHIND="%F{green}NUM⬇%f"
GIT_PROMPT_DELETED="%F{red}NUM◉%f"
GIT_PROMPT_MERGING="%{$fg_bold[magenta]%}Y%{$reset_color%}"
GIT_PROMPT_UNTRACKED="%F{yellow}?%f"
GIT_PROMPT_MODIFIED="%F{blue}✱ %f"
GIT_PROMPT_STAGED="%F{green}✚ %f"
parse_git_branch() {
(git symbolic-ref -q HEAD || git name-rev --name-only --no-undefined --always HEAD) 2> /dev/null
}
parse_git_state() {
local added=0
local deleted=0
local modified=0
local renamed=0
local unmerged=0
local untracked=0
local dirty=0
local status_cmd="git status --porcelain"
while IFS=$'\n' read line; do
[[ "$line" == ([ACDMT][\ MT]|[ACMT]D)\ * ]] && (( added++ ))
[[ "$line" == [\ ACMRT]D\ * ]] && (( deleted++ ))
[[ "$line" == ?[MT]\ * ]] && (( modified++ ))
[[ "$line" == R?\ * ]] && (( renamed++ ))
[[ "$line" == (AA|DD|U?|?U)\ * ]] && (( unmerged++ ))
[[ "$line" == \?\?\ * ]] && (( untracked++ ))
(( dirty++ ))
done < <(${(z)status_cmd} 2> /dev/null)
local GIT_STATE=''
local ahead_and_behind_cmd='git rev-list --count --left-right HEAD...@{upstream}'
local ahead_and_behind="$(${(z)ahead_and_behind_cmd} 2> /dev/null)"
local ahead="$ahead_and_behind[(w)1]"
local behind="$ahead_and_behind[(w)2]"
if (( ahead > 0 )); then
GIT_STATE=$GIT_STATE${GIT_PROMPT_AHEAD//NUM/$ahead}
fi
if (( behind > 0 )); then
GIT_STATE=$GIT_STATE${GIT_PROMPT_BEHIND//NUM/$behind}
fi
if (( added > 0 )); then
GIT_STATE=$GIT_STATE${GIT_PROMPT_STAGED}
fi
if (( deleted > 0 )); then
GIT_STATE=$GIT_STATE${GIT_PROMPT_DELETED//NUM/$deleted}
fi
if (( modified > 0 )); then
GIT_STATE=$GIT_STATE${GIT_PROMPT_MODIFIED}
fi
if (( untracked > 0 )); then
GIT_STATE=$GIT_STATE${GIT_PROMPT_UNTRACKED}
fi
if [[ -n $GIT_STATE ]]; then
echo "$GIT_STATE"
fi
}
git_prompt_string() {
local git_where="$(parse_git_branch)"
[ -n "$git_where" ] && echo "$GIT_PROMPT_PREFIX%F{magenta}${git_where#(refs/heads/|tags/)} $GIT_PROMPT_SYMBOLS$(parse_git_state)$GIT_PROMPT_SUFFIX"
}
RPS1='$(git_prompt_string)'
#RPS1=$GIT_PROMPT_STAGED

View file

@ -0,0 +1,27 @@
#/// My local scripts path
export PATH=$HOME/bin:$PATH
#/// npm
export PATH=$HOME/node_modules/.bin:$PATH
#/// Go
export GOPATH=$HOME/go
export PATH=$PATH:$HOME/go/bin
#/// Lua Rocks
export PATH=$PATH:$HOME/.luarocks/bin
#/// Ruby Gems
export PATH=$PATH:$HOME/.gem/ruby/2.4.0/bin
#/// ccache / colorgcc
# if (( $+commands[colorgcc] )); then
# export PATH="/usr/lib/colorgcc/bin/:$PATH"
# fi
if (( $+commands[ccache] )); then
export CCACHE_PATH="/usr/bin"
export PATH="/usr/lib/ccache/bin/:$PATH"
fi
export VIRSH_DEFAULT_CONNECT_URI="qemu:///system"

106
_install.sh Executable file
View file

@ -0,0 +1,106 @@
#!/bin/sh -e
homedir=$HOME
basedir=$homedir/.dotfiles
bindir=$homedir/bin
gitbase=git://github.com/Klowner/dotfiles.git
gitorigin=git@github.com:Klowner/dotfiles.git
gitbranch=refresh
tarball=http://github.com/Klowner/dotfiles/tarball/$gitbranch
function has() {
return $( which $1 >/dev/null)
}
function note() {
echo "^[[32;1m * ^[[0m$*"
}
function warn() {
echo "^[[31;1m * ^[[0m$*"
}
function die() {
warn $*
exit 1
}
function link() {
src=$1
dst=$2
if [ -e $dst ]; then
if [ -L $dst ]; then
# already symlinked
return
else
# rename files with an ".old" extension
warn "$dst already exists, renaming to $dst.old"
backup=$dst.old
if [ -e $backup ]; then
die "$backup already exists. Aborting."
fi
mv -v $dst $backup
fi
fi
# Update existing or create new symlinks
ln -vsf $src $dst
}
function unpack_tarball() {
note "Downloading tarball..."
mkdir -vp $basedir
cd $basedir
tempfile=TEMP.tar.gz
if has curl; then
curl -L $tarball >$tempfile
elif has wget; then
wget -O $tempfile $tarball
else:
die "Can't download tarball."
fi
tar --strip-components 1 -zxvf $tempfile
rm -v $tempfile
}
if [ -e $basedir ]; then
# basedir exists, update it.
cd $basedir
if [ -e .git ]; then
note "Updating dotfiles from git..."
git pull --rebase origin $gitbranch
else
unpack_tarball
fi
else
# .dotfiles directory needs to be installed. Try downloading first
# with git and then fallback to tarball.
if has git; then
note "Cloning from git..."
git clone $gitbase $basedir
cd $basedir
git submodule init
git submodule update --init --recursive
else
warn "Git not installed."
unpack_tarball
fi
fi
note "Symlinking dotfiles..."
for path in * ; do
# Skip any files beginning with underscores.
if [ $(expr match $path '^_') -eq 1 ]; then
continue
fi
echo link $basedir/$path $HOME/.$path
done
mkdir -p $HOME/.config
for path in _config/*; do
echo link $basedir/_config/$path $HOME/.config/$path
done
note "Done."
# vim:ts=4:sw=4:et:

2
xinitrc Normal file
View file

@ -0,0 +1,2 @@
setxkbmap -option caps:swapescape &
exec i3