Start Refactoring to composable zsh config modules

This commit is contained in:
Marty Oehme 2019-02-18 17:55:05 +01:00
parent 764de81461
commit 71a7ca83c6
24 changed files with 643 additions and 296 deletions

176
.config/i3/config Normal file
View file

@ -0,0 +1,176 @@
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see https://i3wm.org/docs/userguide.html for a complete reference!
set $mod Mod4
# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
#font pango:monospace 8
font Fira Code 8
# This font is widely installed, provides lots of unicode glyphs, right-to-left
# text rendering and scalability on retina/hidpi displays (thanks to pango).
#font pango:DejaVu Sans Mono 8
# Before i3 v4.8, we used to recommend this one as the default:
# font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
# The font above is very space-efficient, that is, it looks good, sharp and
# clear in small sizes. However, its unicode glyph coverage is limited, the old
# X core fonts rendering does not support right-to-left and this being a bitmap
# font, it doesnt scale on retina/hidpi displays.
# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod
# start a terminal
bindsym $mod+Return exec i3-sensible-terminal
# kill focused window
bindsym $mod+Shift+q kill
# start dmenu (a program launcher)
#bindsym $mod+space exec dmenu_run
# There also is the (new) i3-dmenu-desktop which only displays applications
# shipping a .desktop file. It is a wrapper around dmenu, so you need that
# installed.
bindsym $mod+space exec --no-startup-id i3-dmenu-desktop
# change focus
bindsym $mod+h focus left
bindsym $mod+j focus down
bindsym $mod+k focus up
bindsym $mod+l focus right
# alternatively, you can use the cursor keys:
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right
# move focused window
bindsym $mod+Shift+h move left
bindsym $mod+Shift+j move down
bindsym $mod+Shift+k move up
bindsym $mod+Shift+l move right
# alternatively, you can use the cursor keys:
bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right
# split in horizontal orientation
bindsym $mod+odiaeresis split h
# split in vertical orientation
bindsym $mod+v split v
bindsym $mod+Odiaeresis split v #odiaeresis
# enter fullscreen mode for the focused container
bindsym $mod+f fullscreen toggle
# change container layout (stacked, tabbed, toggle split)
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split
# toggle tiling / floating
bindsym $mod+Shift+space floating toggle
# change focus between tiling / floating windows
#bindsym $mod+space focus mode_toggle
# focus the parent container
bindsym $mod+a focus parent
# focus the child container
#bindsym $mod+d focus child
# Define names for default workspaces for which we configure key bindings later on.
# We use variables to avoid repeating the names in multiple places.
set $ws1 "1"
set $ws2 "2"
set $ws3 "3"
set $ws4 "4"
set $ws5 "5"
set $ws6 "6"
set $ws7 "7"
set $ws8 "8"
set $ws9 "9"
set $ws10 "10"
# switch to workspace
bindsym $mod+1 workspace $ws1
bindsym $mod+2 workspace $ws2
bindsym $mod+3 workspace $ws3
bindsym $mod+4 workspace $ws4
bindsym $mod+5 workspace $ws5
bindsym $mod+6 workspace $ws6
bindsym $mod+7 workspace $ws7
bindsym $mod+8 workspace $ws8
bindsym $mod+9 workspace $ws9
bindsym $mod+0 workspace $ws10
# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace $ws1
bindsym $mod+Shift+2 move container to workspace $ws2
bindsym $mod+Shift+3 move container to workspace $ws3
bindsym $mod+Shift+4 move container to workspace $ws4
bindsym $mod+Shift+5 move container to workspace $ws5
bindsym $mod+Shift+6 move container to workspace $ws6
bindsym $mod+Shift+7 move container to workspace $ws7
bindsym $mod+Shift+8 move container to workspace $ws8
bindsym $mod+Shift+9 move container to workspace $ws9
bindsym $mod+Shift+0 move container to workspace $ws10
# reload the configuration file
bindsym $mod+Shift+c reload
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Shift+r restart
# exit i3 (logs you out of your X session)
bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'"
bindsym $mod+Shift+z exec "i3-nagbar -m 'I am not useful?' -B 'Agreed!' 'i3-msg exit'"
# resize window (you can also use the mouse for that)
mode "resize" {
# These bindings trigger as soon as you enter the resize mode
# Pressing left will shrink the windows width.
# Pressing right will grow the windows width.
# Pressing up will shrink the windows height.
# Pressing down will grow the windows height.
bindsym h resize shrink width 10 px or 10 ppt
bindsym j resize grow height 10 px or 10 ppt
bindsym k resize shrink height 10 px or 10 ppt
bindsym l resize grow width 10 px or 10 ppt
# same bindings, but for the arrow keys
bindsym Left resize shrink width 10 px or 10 ppt
bindsym Down resize grow height 10 px or 10 ppt
bindsym Up resize shrink height 10 px or 10 ppt
bindsym Right resize grow width 10 px or 10 ppt
# back to normal: Enter or Escape or $mod+r
bindsym Return mode "default"
bindsym Escape mode "default"
bindsym $mod+r mode "default"
}
bindsym $mod+r mode "resize"
# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
bar {
status_command i3status
}
bindsym $mod+shift+x exec i3lock

17
.zgenrc
View file

@ -103,9 +103,6 @@ load-starter-plugin-list() {
# Docker completion
zgen load srijanshetty/docker-zsh
# Load me last
GENCOMPL_FPATH=$HOME/.zsh/complete
# 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.
@ -131,20 +128,16 @@ load-starter-plugin-list() {
# radically enhanced cd command, all sorts of options
zgen load b4b4r07/enhancd
# set up nvm, the npm version manager
zgen load lukechilds/zsh-nvm
# Load me last
GENCOMPL_FPATH=$HOME/.zsh/complete
# Save it all to init script.
zgen save
}
setup-zgen-repos() {
if [[ -f ~/.zgen-local-plugins ]]; then
source ~/.zgen-local-plugins
else
load-starter-plugin-list
fi
}
# This comes from https://stackoverflow.com/questions/17878684/best-way-to-get-file-modified-time-in-seconds
# This works on both Linux with GNU fileutils and macOS with BSD stat.
@ -168,7 +161,7 @@ fi
# check if there's an init.zsh file for zgen and generate one if not.
if ! zgen saved; then
setup-zgen-repos
load-starter-plugin-list
fi

27
.zsh.d/01-history Normal file
View file

@ -0,0 +1,27 @@
### Set ZSH History defaults
# set some history options
setopt append_history
setopt extended_history
setopt hist_expire_dups_first
setopt hist_ignore_all_dups
setopt hist_ignore_dups
setopt hist_ignore_space
setopt hist_reduce_blanks
setopt hist_save_no_dups
setopt hist_verify
# Share your history across all your terminal windows
setopt share_history
#setopt noclobber
# set some more options
setopt pushd_ignore_dups
#setopt pushd_silent
# Keep a ton of history.
HISTSIZE=100000
SAVEHIST=100000
HISTFILE=~/.zsh_history
export HISTIGNORE="ls:cd:cd -:pwd:exit:date:* --help"

View file

@ -0,0 +1,14 @@
# Expand aliases inline - see http://blog.patshead.com/2012/11/automatically-expaning-zsh-global-aliases---simplified.html
globalias() {
if [[ $LBUFFER =~ ' [A-Z0-9]+$' ]]; then
zle _expand_alias
zle expand-word
fi
zle self-insert
}
zle -N globalias
bindkey " " globalias
bindkey "^ " magic-space # control-space to bypass completion
bindkey -M isearch " " magic-space # normal space during searches

View file

@ -0,0 +1,11 @@
# deal with screen, if we're using it - courtesy MacOSXHints.com
# Login greeting ------------------
if [ "$TERM" = "screen" -a ! "$SHOWED_SCREEN_MESSAGE" = "true" ]; then
detached_screens=$(screen -list | grep Detached)
if [ ! -z "$detached_screens" ]; then
echo "+---------------------------------------+"
echo "| Detached screens are available: |"
echo "$detached_screens"
echo "+---------------------------------------+"
fi
fi

View file

@ -0,0 +1,2 @@
# enables git management through dotfiles command
alias dotfiles='/usr/bin/git --git-dir=/home/marty/.dotfiles/ --work-tree=/home/marty'

View file

@ -0,0 +1 @@
export LC_ALL="en_US.utf-8"

View file

@ -0,0 +1,4 @@
# Long running processes should return time after they complete. Specified
# in seconds.
REPORTTIME=2
TIMEFMT="%U user %S system %P cpu %*Es total"

View file

@ -0,0 +1,232 @@
## Integration at the Bottom
# Copyright (C) 2011 by Wayne Walker <wwalker@solid-constructs.com>
#
# Released under one of the versions of the MIT License.
#
# Copyright (C) 2011 by Wayne Walker <wwalker@solid-constructs.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
_LIVE_AGENT_LIST=""
declare -a _LIVE_AGENT_SOCK_LIST
_LIVE_AGENT_SOCK_LIST=()
_debug_print() {
if [[ $_DEBUG -gt 0 ]]
then
printf "%s\n" $1
fi
}
find_all_ssh_agent_sockets() {
_SSH_AGENT_SOCKETS=`find /tmp/ -type s -name agent.\* 2> /dev/null | grep '/tmp/ssh-.*/agent.*'`
_debug_print "$_SSH_AGENT_SOCKETS"
}
find_all_gpg_agent_sockets() {
_GPG_AGENT_SOCKETS=`find /tmp/ -type s -name S.gpg-agent.ssh 2> /dev/null | grep '/tmp/gpg-.*/S.gpg-agent.ssh'`
_debug_print "$_GPG_AGENT_SOCKETS"
}
find_all_gnome_keyring_agent_sockets() {
_GNOME_KEYRING_AGENT_SOCKETS=`find /tmp/ -type s -name ssh 2> /dev/null | grep '/tmp/keyring-.*/ssh$'`
_debug_print "$_GNOME_KEYRING_AGENT_SOCKETS"
}
find_all_osx_keychain_agent_sockets() {
[[ -n "$TMPDIR" ]] || TMPDIR=/tmp
_OSX_KEYCHAIN_AGENT_SOCKETS=`find $TMPDIR/ -type s -regex '.*/ssh-.*/agent..*$' 2> /dev/null`
_debug_print "$_OSX_KEYCHAIN_AGENT_SOCKETS"
}
test_agent_socket() {
local SOCKET=$1
SSH_AUTH_SOCK=$SOCKET ssh-add -l 2> /dev/null > /dev/null
result=$?
_debug_print $result
if [[ $result -eq 0 ]]
then
# contactible and has keys loaded
_KEY_COUNT=`SSH_AUTH_SOCK=$SOCKET ssh-add -l | wc -l | tr -d ' '`
fi
if [[ $result -eq 1 ]]
then
# contactible butno keys loaded
_KEY_COUNT=0
fi
if [[ ( ( $result -eq 0 ) || ( $result -eq 1 ) ) ]]
then
if [[ -n "$_LIVE_AGENT_LIST" ]]
then
_LIVE_AGENT_LIST="${_LIVE_AGENT_LIST} ${SOCKET}:$_KEY_COUNT"
else
_LIVE_AGENT_LIST="${SOCKET}:$_KEY_COUNT"
fi
return 0
fi
return 1
}
find_live_gnome_keyring_agents() {
for i in $_GNOME_KEYRING_AGENT_SOCKETS
do
test_agent_socket $i
done
}
find_live_osx_keychain_agents() {
for i in $_OSX_KEYCHAIN_AGENT_SOCKETS
do
test_agent_socket $i
done
}
find_live_gpg_agents() {
for i in $_GPG_AGENT_SOCKETS
do
test_agent_socket $i
done
}
find_live_ssh_agents() {
for i in $_SSH_AGENT_SOCKETS
do
test_agent_socket $i
done
}
function fingerprints() {
local file="$1"
while read l; do
[[ -n $l && ${l###} = $l ]] && ssh-keygen -l -f /dev/stdin <<<$l
done < $file
}
find_all_agent_sockets() {
_SHOW_IDENTITY=0
if [ "$1" = "-i" ] ; then
_SHOW_IDENTITY=1
fi
_LIVE_AGENT_LIST=
find_all_ssh_agent_sockets
find_all_gpg_agent_sockets
find_all_gnome_keyring_agent_sockets
find_all_osx_keychain_agent_sockets
find_live_ssh_agents
find_live_gpg_agents
find_live_gnome_keyring_agents
find_live_osx_keychain_agents
_debug_print "$_LIVE_AGENT_LIST"
_LIVE_AGENT_LIST=$(echo $_LIVE_AGENT_LIST | tr ' ' '\n' | sort -n -t: -k 2 -k 1 | uniq)
_LIVE_AGENT_SOCK_LIST=()
_debug_print "SORTED: $_LIVE_AGENT_LIST"
if [ -e ~/.ssh/authorized_keys ] ; then
_FINGERPRINTS=$(fingerprints ~/.ssh/authorized_keys)
fi
if [[ $_SHOW_IDENTITY -gt 0 ]]
then
i=0
for a in $_LIVE_AGENT_LIST ; do
sock=${a/:*/}
_LIVE_AGENT_SOCK_LIST[$i]=$sock
# technically we could have multiple keys forwarded
# But I haven't seen anyone do it
akeys=$(SSH_AUTH_SOCK=$sock ssh-add -l)
key_size=$(echo ${akeys} | awk '{print $1}')
fingerprint=$(echo ${akeys} | awk '{print $2}')
remote_name=$(echo ${akeys} | awk '{print $3}')
if [ -e ~/.ssh/authorized_keys ] ; then
authorized_entry=$(fingerprints ~/.ssh/authorized_keys | grep $fingerprint)
fi
comment=$(echo ${authorized_entry} | awk '{print $3,$4,$5,$6,$7}')
printf "export SSH_AUTH_SOCK=%s \t#%i) \t%s\n" "$sock" $((i+1)) "$comment"
i=$((i+1))
done
else
printf "%s\n" "$_LIVE_AGENT_LIST" | sed -e 's/ /\n/g' | sort -n -t: -k 2 -k 1
fi
}
set_ssh_agent_socket() {
if [ "$1" = "-c" -o "$1" = "--choose" ]
then
find_all_agent_sockets -i
if [ -z "$_LIVE_AGENT_LIST" ] ; then
echo "No agents found"
return 1
fi
echo -n "Choose (1-${#_LIVE_AGENT_SOCK_LIST[@]})? "
read choice
if [ -n "$choice" ]
then
n=$((choice-1))
if [ -z "${_LIVE_AGENT_SOCK_LIST[$n]}" ] ; then
echo "Invalid choice"
return 1
fi
echo "Setting export SSH_AUTH_SOCK=${_LIVE_AGENT_SOCK_LIST[$n]}"
export SSH_AUTH_SOCK=${_LIVE_AGENT_SOCK_LIST[$n]}
fi
else
# Choose the first available
SOCK=$(find_all_agent_sockets|tail -n 1|awk -F: '{print $1}')
if [ -z "$SOCK" ] ; then
return 1
fi
export SSH_AUTH_SOCK=$SOCK
fi
# set agent pid
if [ -n "$SSH_AUTH_SOCK" ] ; then
export SSH_AGENT_PID=$((`echo $SSH_AUTH_SOCK | cut -d. -f2` + 1))
fi
return 0
}
ssh-find-agent() {
if [ "$1" = "-c" -o "$1" = "--choose" ]
then
set_ssh_agent_socket -c
return $?
elif [ "$1" = "-a" -o "$1" = "--auto" ]
then
set_ssh_agent_socket
return $?
else
find_all_agent_sockets -i
return 0
fi
}
# Automatically add ssh-agent to any new ssh connection
ssh-find-agent -a
if [ -z "$SSH_AUTH_SOCK" ]
then
eval $(ssh-agent) > /dev/null
ssh-add -l >/dev/null || alias ssh='ssh-add -l >/dev/null || ssh-add && unalias ssh; ssh'
fi

View file

@ -0,0 +1,11 @@
# Correct spelling for commands
setopt correct
# turn off the infernal correctall for filenames
unsetopt correctall
# Enable command auto-correction.
ENABLE_CORRECTION="true"
# Display red dots whilst waiting for completion.
COMPLETION_WAITING_DOTS="true"

View file

@ -0,0 +1,40 @@
POWERLEVEL9K_MODE='nerdfont-complete'
#POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
#POWERLEVEL9K_SHORTEN_DELIMITER=""
#POWERLEVEL9K_SHORTEN_STRATEGY="truncate_from_right"
POWERLEVEL9K_PROMPT_ON_NEWLINE=true
POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR=''
POWERLEVEL9K_RIGHT_SEGMENT_SEPARATOR=''
POWERLEVEL9K_LEFT_SUBSEGMENT_SEPARATOR=''
POWERLEVEL9K_RIGHT_SUBSEGMENT_SEPARATOR=''
POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX="%F{blue}\u256D\u2500%F{white}"
POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX="%F{blue}\u2570\uf460%F{white} "
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(root_indicator dir dir_writable_joined)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(command_execution_time
vcs background_jobs_joined time_joined)
POWERLEVEL9K_VCS_MODIFIED_BACKGROUND="clear"
POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND="clear"
POWERLEVEL9K_VCS_MODIFIED_FOREGROUND="yellow"
POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND="yellow"
POWERLEVEL9K_DIR_HOME_BACKGROUND="clear"
POWERLEVEL9K_DIR_HOME_FOREGROUND="blue"
POWERLEVEL9K_DIR_HOME_SUBFOLDER_BACKGROUND="clear"
POWERLEVEL9K_DIR_HOME_SUBFOLDER_FOREGROUND="blue"
POWERLEVEL9K_DIR_WRITABLE_FORBIDDEN_BACKGROUND="clear"
POWERLEVEL9K_DIR_WRITABLE_FORBIDDEN_FOREGROUND="red"
POWERLEVEL9K_DIR_DEFAULT_BACKGROUND="clear"
POWERLEVEL9K_DIR_DEFAULT_FOREGROUND="white"
POWERLEVEL9K_ROOT_INDICATOR_BACKGROUND="red"
POWERLEVEL9K_ROOT_INDICATOR_FOREGROUND="white"
POWERLEVEL9K_STATUS_OK_BACKGROUND="clear"
POWERLEVEL9K_STATUS_OK_FOREGROUND="green"
POWERLEVEL9K_STATUS_ERROR_BACKGROUND="clear"
POWERLEVEL9K_STATUS_ERROR_FOREGROUND="red"
POWERLEVEL9K_TIME_BACKGROUND="clear"
POWERLEVEL9K_TIME_FOREGROUND="cyan"
POWERLEVEL9K_COMMAND_EXECUTION_TIME_BACKGROUND='clear'
POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND='magenta'
POWERLEVEL9K_BACKGROUND_JOBS_BACKGROUND='clear'
POWERLEVEL9K_BACKGROUND_JOBS_FOREGROUND='green'
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=250"

View file

@ -0,0 +1,13 @@
# Speed up autocomplete, force prefix mapping
zstyle ':completion:*' accept-exact '*(N)'
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zsh/cache
zstyle -e ':completion:*:default' list-colors 'reply=("${PREFIX:+=(#bi)($PREFIX:t)*==34=34}:${(s.:.)LS_COLORS}")';
# Load any custom zsh completions we've installed
if [ -d ~/.zsh-completions ]; then
for completion in ~/.zsh-completions/*
do
source "$completion"
done
fi

View file

@ -0,0 +1,19 @@
# In case a plugin adds a redundant path entry, remove duplicate entries
# from PATH
#
# This snippet is from Mislav Marohnić <mislav.marohnic@gmail.com>'s
# dotfiles repo at https://github.com/mislav/dotfiles
dedupe_path() {
typeset -a paths result
paths=($path)
while [[ ${#paths} -gt 0 ]]; do
p="${paths[1]}"
shift paths
[[ -z ${paths[(r)$p]} ]] && result+="$p"
done
export PATH=${(j+:+)result}
}
dedupe_path

View file

@ -1,25 +1,22 @@
# Prettify ls commands
if [[ "$(uname -s)" == "Linux" ]]; then
# we're on linux
alias l-d="ls -lFad"
# alias l="ls -lAhF" # Overwritten by using k in .zsh.d/004-k-alias
alias l="ls -lAhF" # Overwritten for k in -aliasing-k
alias ll="ls -lFa | TERM=vt100 less"
alias ls='ls --color=auto'
fi
# enables git management through dotfiles command
alias dotfiles='/usr/bin/git --git-dir=/home/marty/.dotfiles/ --work-tree=/home/marty'
alias n='nnn'
alias m='micro'
alias zshconf='m ~/.zshrc'
# Show the top 5 commands used in recent history
alias historysummary="history | awk '{a[\$2]++} END{for(i in a){printf \"%5d\t%s\n\",a[i],i}}' | sort -rn | head"
alias myip="curl -s icanhazip.com"
# Display timestamped recent command history
alias zh="fc -l -d -D"
# alias ..="cd .." # overwritten by enhancd config in .zshrc.d/
# Display your current ip address
alias myip="curl -s icanhazip.com"
# move around faster for often used cd commands
alias ..="cd .." # overwritten by enhancd config in .zshrc.d/
alias ...="cd ../.."
alias ~="cd ~"

3
.zsh.d/35-alias-k-to-l Normal file
View file

@ -0,0 +1,3 @@
# uses k (installed with plugins) but makes it accessible through l as well
alias k="k -h"
alias l="k -A"

View file

@ -0,0 +1,4 @@
# Assumes enhancd is installed (via plugin)
# Let's you go back a directory with .. (usual cd .. behavior)
# Let's the enhancd backtrack menu appear with cd .. (usual enhancd behavior)
alias ..="ENHANCD_DISABLE_DOT=1 cd .."

View file

@ -1,4 +1,4 @@
#automatically use tmux whenever we ssh to a server
# automatically use tmux whenever we ssh to a server
function ssht(){
ssh $* -t 'tmux a || tmux || /bin/bash'

314
.zshrc
View file

@ -1,264 +1,92 @@
# Correct spelling for commands
setopt correct
#!/bin/zsh
#### ZSHRC - Setting up the Shell
##
## Almost all actual setup is being done with the help of individual files
## in the .zsh.d/ directory. They follow a specific order:
##
## 00-09 are bootstrapping the zsh environment, setting aliases and sane
## shell defaults which should need no changes
## 10-19 allow custom bootstrapping of things that need to be set before any
## zsh plugins are loaded (in my case, theme environment vars, etc)
## 20-29 are run *during* zgen setup and can include plugins to be loaded
## 30-99 are run after plugins are loaded and can be configured
## in whatever way you wish
##
## 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.
# turn off the infernal correctall for filenames
unsetopt correctall
#ZSH_TMUX_AUTOSTART=true
export LC_ALL="en_US.utf-8"
POWERLEVEL9K_MODE='nerdfont-complete'
#POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
#POWERLEVEL9K_SHORTEN_DELIMITER=""
#POWERLEVEL9K_SHORTEN_STRATEGY="truncate_from_right"
POWERLEVEL9K_PROMPT_ON_NEWLINE=true
POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR=''
POWERLEVEL9K_RIGHT_SEGMENT_SEPARATOR=''
POWERLEVEL9K_LEFT_SUBSEGMENT_SEPARATOR=''
POWERLEVEL9K_RIGHT_SUBSEGMENT_SEPARATOR=''
POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX="%F{blue}\u256D\u2500%F{white}"
POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX="%F{blue}\u2570\uf460%F{white} "
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(root_indicator dir dir_writable_joined)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(command_execution_time
vcs background_jobs_joined time_joined)
POWERLEVEL9K_VCS_MODIFIED_BACKGROUND="clear"
POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND="clear"
POWERLEVEL9K_VCS_MODIFIED_FOREGROUND="yellow"
POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND="yellow"
POWERLEVEL9K_DIR_HOME_BACKGROUND="clear"
POWERLEVEL9K_DIR_HOME_FOREGROUND="blue"
POWERLEVEL9K_DIR_HOME_SUBFOLDER_BACKGROUND="clear"
POWERLEVEL9K_DIR_HOME_SUBFOLDER_FOREGROUND="blue"
POWERLEVEL9K_DIR_WRITABLE_FORBIDDEN_BACKGROUND="clear"
POWERLEVEL9K_DIR_WRITABLE_FORBIDDEN_FOREGROUND="red"
POWERLEVEL9K_DIR_DEFAULT_BACKGROUND="clear"
POWERLEVEL9K_DIR_DEFAULT_FOREGROUND="white"
POWERLEVEL9K_ROOT_INDICATOR_BACKGROUND="red"
POWERLEVEL9K_ROOT_INDICATOR_FOREGROUND="white"
POWERLEVEL9K_STATUS_OK_BACKGROUND="clear"
POWERLEVEL9K_STATUS_OK_FOREGROUND="green"
POWERLEVEL9K_STATUS_ERROR_BACKGROUND="clear"
POWERLEVEL9K_STATUS_ERROR_FOREGROUND="red"
POWERLEVEL9K_TIME_BACKGROUND="clear"
POWERLEVEL9K_TIME_FOREGROUND="cyan"
POWERLEVEL9K_COMMAND_EXECUTION_TIME_BACKGROUND='clear'
POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND='magenta'
POWERLEVEL9K_BACKGROUND_JOBS_BACKGROUND='clear'
POWERLEVEL9K_BACKGROUND_JOBS_FOREGROUND='green'
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=250"
# Uncomment the following line to enable command auto-correction.
ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
COMPLETION_WAITING_DOTS="true"
# start zgen
if [ -f ~/.zgenrc ]; then
source ~/.zgenrc
fi
# set some history options
setopt append_history
setopt extended_history
setopt hist_expire_dups_first
setopt hist_ignore_all_dups
setopt hist_ignore_dups
setopt hist_ignore_space
setopt hist_reduce_blanks
setopt hist_save_no_dups
setopt hist_verify
# Share your history across all your terminal windows
setopt share_history
#setopt noclobber
# set some more options
setopt pushd_ignore_dups
#setopt pushd_silent
# Keep a ton of history.
HISTSIZE=100000
SAVEHIST=100000
HISTFILE=~/.zsh_history
export HISTIGNORE="ls:cd:cd -:pwd:exit:date:* --help"
# Long running processes should return time after they complete. Specified
# in seconds.
REPORTTIME=2
TIMEFMT="%U user %S system %P cpu %*Es total"
# How often to check for an update. If you want to override this, the
# easiest way is to add a script fragment in ~/.zshrc.d that unsets
# QUICKSTART_KIT_REFRESH_IN_DAYS.
QUICKSTART_KIT_REFRESH_IN_DAYS=7
# Expand aliases inline - see http://blog.patshead.com/2012/11/automatically-expaning-zsh-global-aliases---simplified.html
globalias() {
if [[ $LBUFFER =~ ' [A-Z0-9]+$' ]]; then
zle _expand_alias
zle expand-word
fi
zle self-insert
## 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 $@
}
zle -N globalias
bindkey " " globalias
bindkey "^ " magic-space # control-space to bypass completion
bindkey -M isearch " " magic-space # normal space during searches
# Stuff only tested on zsh, or explicitly zsh-specific
if [ -r ~/.zsh_aliases ]; then
source ~/.zsh_aliases
fi
# deal with screen, if we're using it - courtesy MacOSXHints.com
# Login greeting ------------------
if [ "$TERM" = "screen" -a ! "$SHOWED_SCREEN_MESSAGE" = "true" ]; then
detached_screens=$(screen -list | grep Detached)
if [ ! -z "$detached_screens" ]; then
echo "+---------------------------------------+"
echo "| Detached screens are available: |"
echo "$detached_screens"
echo "+---------------------------------------+"
# Set ZSH_CONFIG_DIR to default to ~/.zsh.d, or let user override
# Exit early if no configuration directory has been found
if [ ! -d ${ZSH_CONFIG_DIR:="$HOME/.zsh.d"} ]; then
# If the user explicitly overrode the path give him an error
if [ ! $ZSH_CONFIG_DIR = "$HOME/.zsh.d" ]; then
printf "\$ZSH_CONFIG_DIR=$ZSH_CONFIG_DIR/ does not exist.\n"
fi
PS1="$HOME $ "
return
fi
# Speed up autocomplete, force prefix mapping
zstyle ':completion:*' accept-exact '*(N)'
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zsh/cache
zstyle -e ':completion:*:default' list-colors 'reply=("${PREFIX:+=(#bi)($PREFIX:t)*==34=34}:${(s.:.)LS_COLORS}")';
# Load any custom zsh completions we've installed
if [ -d ~/.zsh-completions ]; then
for completion in ~/.zsh-completions/*
do
source "$completion"
done
fi
# Make it easy to append your own customizations that override the above by
# loading all files from the ~/.zshrc.d directory
mkdir -p ~/.zshrc.d
if [ -n "$(/bin/ls ~/.zshrc.d)" ]; then
for dotfile in ~/.zshrc.d/*
do
# //TODO: Prints error when -no- files are found
# Load bootstrap settings (00-19) before plugin initialization
if [ -n "$(/bin/ls $ZSH_CONFIG_DIR/)" ]; then
GLOB=($ZSH_CONFIG_DIR/[0-1][0-9]-*)
for dotfile in $GLOB; do
print_dbg "Phase 1: $dotfile\n" #//DEBUG
if [ -r "${dotfile}" ]; then
source "${dotfile}"
fi
done
unset GLOB
fi
# In case a plugin adds a redundant path entry, remove duplicate entries
# from PATH
#
# This snippet is from Mislav Marohnić <mislav.marohnic@gmail.com>'s
# dotfiles repo at https://github.com/mislav/dotfiles
dedupe_path() {
typeset -a paths result
paths=($path)
# set up zgen - load external zsh plugins
if [ -f ~/.zgenrc ]; then
print_dbg "Phase 2: Setting up ZGEN\n" #//DEBUG
source ~/.zgenrc
fi
while [[ ${#paths} -gt 0 ]]; do
p="${paths[1]}"
shift paths
[[ -z ${paths[(r)$p]} ]] && result+="$p"
# Load additional settings (30-99) after plugin initialization
if [ -n "$(/bin/ls $ZSH_CONFIG_DIR/)" ]; then
GLOB=($ZSH_CONFIG_DIR/[3-9][0-9]-*)
for dotfile in $GLOB; do
print_dbg "Phase 3: $dotfile\n" #//DEBUG
if [ -r "${dotfile}" ]; then
source "${dotfile}"
fi
done
unset GLOB
fi
export PATH=${(j+:+)result}
}
dedupe_path
# Do selfupdate checking. We do this after processing ~/.zshrc.d to make the
# refresh check interval easier to customize.
#
# If they unset QUICKSTART_KIT_REFRESH_IN_DAYS in one of the fragments
# in ~/.zshrc.d, then we don't do any selfupdate checking at all.
_load-lastupdate-from-file() {
local now=$(date +%s)
if [[ -f "${1}" ]]; then
local last_update=$(cat "${1}")
else
local last_update=0
fi
local interval="$(expr ${now} - ${last_update})"
echo "${interval}"
}
_update-zsh-quickstart() {
if [[ ! -L ~/.zshrc ]]; then
echo ".zshrc is not a symlink, skipping zsh-quickstart-kit update"
else
local _link_loc=$(readlink ~/.zshrc);
if [[ "${_link_loc/${HOME}}" == "${_link_loc}" ]] then
pushd $(dirname "${HOME}/$(readlink ~/.zshrc)");
else
pushd $(dirname ${_link_loc});
fi;
local gitroot=$(git rev-parse --show-toplevel)
if [[ -f "${gitroot}/.gitignore" ]]; then
if [[ $(grep -c zsh-quickstart-kit "${gitroot}/.gitignore") -ne 0 ]]; then
echo "---- updating ----"
git pull
date +%s >! ~/.zsh-quickstart-last-update
fi
else
echo 'No quickstart marker found, is your quickstart a valid git checkout?'
fi
popd
fi
}
_check-for-zsh-quickstart-update() {
local day_seconds=$(expr 24 \* 60 \* 60)
local refresh_seconds=$(expr "${day_seconds}" \* "${QUICKSTART_KIT_REFRESH_IN_DAYS}")
local last_quickstart_update=$(_load-lastupdate-from-file ~/.zsh-quickstart-last-update)
if [ ${last_quickstart_update} -gt ${refresh_seconds} ]; then
echo "It has been $(expr ${last_quickstart_update} / ${day_seconds}) days since your zsh quickstart kit was updated"
echo "Checking for zsh-quickstart-kit updates..."
_update-zsh-quickstart
fi
}
#
# if [[ ! -z "$QUICKSTART_KIT_REFRESH_IN_DAYS" ]]; then
# _check-for-zsh-quickstart-update
# unset QUICKSTART_KIT_REFRESH_IN_DAYS
# 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 "Phase 4, Alphabetic: $dotfile\n" #//DEBUG
# if [ -r "${dotfile}" ]; then
# source "${dotfile}"
# fi
# done
# unset GLOB
# fi
# You may need to manually set your language environment
#export LANG=en_US.UTF-8
unset ZSH_CONFIG_DIR
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
#PS1='[\u@\h \W]\$ '
# >>> Added by cnchi installer
BROWSER=/usr/bin/chromium
EDITOR=/usr/bin/micro
if [[ -f ~/.ssh/.ssh-find-agent.sh ]] then
. ~/.ssh/.ssh-find-agent.sh
ssh-find-agent -a
fi
if [ -z "$SSH_AUTH_SOCK" ]
then
eval $(ssh-agent) > /dev/null
ssh-add -l >/dev/null || alias ssh='ssh-add -l >/dev/null || ssh-add && unalias ssh; ssh'
fi
export GOPATH="$HOME/Code/go"
export PATH="$PATH:$GOPATH/bin"

View file

@ -1,25 +0,0 @@
# Create short urls via http://goo.gl using curl(1).
# Contributed back to grml zshrc
# API reference: https://code.google.com/apis/urlshortener/
function zurl {
if [[ -z $1 ]]; then
print "USAGE: $0 <URL>"
return 1
fi
local url=$1
local api='https://www.googleapis.com/urlshortener/v1/url'
local data
# Prepend "http://" to given URL where necessary for later output.
if [[ $url != http(s|)://* ]]; then
url="http://$url"
fi
local json="{\"longUrl\": \"$url\"}"
data=$(curl --silent -H "Content-Type: application/json" -d $json $api)
# Match against a regex and print it
if [[ $data =~ '"id": "(http://goo.gl/[[:alnum:]]+)"' ]]; then
print $match
fi
}

View file

@ -1,2 +0,0 @@
alias k="k -h"
alias l="k -A"

View file

@ -1 +0,0 @@
alias ..="ENHANCD_DISABLE_DOT=1 cd .."