Compare commits
13 Commits
zcurses/bu
...
2ac97afdd1
| Author | SHA1 | Date | |
|---|---|---|---|
| 2ac97afdd1 | |||
| f24253b8c1 | |||
| df819f58a8 | |||
| c636dd078c | |||
| 0992b65d17 | |||
| 9e9c43a0cf | |||
| 0ab04406ec | |||
| e17ff47d5e | |||
| ff8bb3e4ab | |||
| 31d06e0f19 | |||
| 7bb6a459ee | |||
| 9e4c984822 | |||
| 9af452a8e2 |
@@ -6,8 +6,8 @@
|
||||
- brew:
|
||||
- zsh
|
||||
- command:
|
||||
- install: sudo chsh $USER -s `which zsh`
|
||||
remove: sudo chsh $USER -s `which bash`
|
||||
- install: sudo chsh -s `which zsh` $USER
|
||||
remove: sudo chsh -s `which bash` $USER
|
||||
- symlink:
|
||||
- {src: zlogin, dst: ~/.zlogin}
|
||||
- {src: zlogout, dst: ~/.zlogout}
|
||||
|
||||
22
README.md
22
README.md
@@ -51,10 +51,26 @@ display. This results in no noticeable lag when redrawing the prompt.
|
||||
Plugins are sourced manually and their git repositories tracked by
|
||||
[conduit][conduit], no plugin manager is used.
|
||||
|
||||
* [zsh-syntax-highlighting][syntax] Fish shell like syntax highlighting for Zsh.
|
||||
* [zsh-autosuggestions][zsh-autosuggestions] Fish-like autosuggestions for zsh.
|
||||
* [fast-syntax-highlighting][syntax] Optimized and extended
|
||||
zsh-syntax-highlighting - Fish shell like syntax highlighting for Zsh.
|
||||
* [zsh-history-substring-search][search] Zsh port of the Fish shell's history
|
||||
search.
|
||||
|
||||
In addition to third party plugins the following are custom plugins residing in
|
||||
this repository.
|
||||
|
||||
* [autoenv](autoenv/autoenv.zsh) is a inspired by [zsh-autoenv][zsh-autoenv] but
|
||||
simplified by removing customization points and using a less intrusive UI.
|
||||
* [build](build/build.plugin.zsh) is a collection of commands to make it easier
|
||||
to build projects focuses on C/C++ development.
|
||||
* [sandbox](sandbox/sandbox.plugin.zsh) is a command which sets up a throw away
|
||||
directory for quickly testing ideas.
|
||||
* [layout](layout/layout.plugin.zsh) is a command which setups up `tmux` panes
|
||||
in a window with scripts.
|
||||
* [notes](notes/notes.plugin.zsh) is a command to quickly edit markdown note
|
||||
files.
|
||||
|
||||
## Environment & Settings
|
||||
|
||||
The bulk of, if not all, configuration occurs in [`zshenv`](zshenv) and
|
||||
@@ -135,7 +151,9 @@ Various aliases are defined at the end of [zshrc](zshrc) for convenience.
|
||||
[zsh]: https://www.zsh.org/
|
||||
[git]: https://git-scm.com/
|
||||
[git-prompt]: https://github.com/olivierverdier/zsh-git-prompt
|
||||
[syntax]: https://github.com/zsh-users/zsh-syntax-highlighting
|
||||
[zsh-autosuggestions]: https://github.com/zdharma/fast-syntax-highlighting
|
||||
[zsh-autoenv]: https://github.com/Tarrasch/zsh-autoenv
|
||||
[syntax]: https://github.com/zdharma/fast-syntax-highlighting
|
||||
[search]: https://github.com/zsh-users/zsh-history-substring-search
|
||||
[vim-mode]: https://github.com/sharat87/zsh-vim-mode
|
||||
[tmux]: https://tmux.github.io
|
||||
|
||||
@@ -75,6 +75,9 @@ commands:
|
||||
# Global entered directories array.
|
||||
_autoenv_entered=()
|
||||
|
||||
# Load zstat from stat module for inspecting modified time.
|
||||
zmodload -F zsh/stat b:zstat
|
||||
|
||||
# Check if the given file is authorized, if not prompt the user to authorize,
|
||||
# ignore, or view the file. Authorized files and their modified times are
|
||||
# stored in the ~/.cache/autoenv/authorized file to make authorization
|
||||
|
||||
@@ -149,7 +149,9 @@ EOF
|
||||
hash -d build=$build_dir
|
||||
|
||||
# If `--build` is specified then evaluate the command.
|
||||
[[ -n $do_build ]] && eval build
|
||||
if [[ -n $do_build ]]; then
|
||||
eval build
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#compdef layout
|
||||
|
||||
__get_layouts() {
|
||||
ls -1 ~/.config/tmux/layouts 2>/dev/null | \
|
||||
ls -1 ~/.local/share/tmux/layouts 2>/dev/null | \
|
||||
while read -r layout; do echo $layout; done
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ layout() {
|
||||
if [[ "$1" == "" ]]; then
|
||||
echo "usage: layout <layout> [name]"
|
||||
else
|
||||
tmux source-file ~/.config/tmux/layouts/$1
|
||||
tmux source-file ~/.local/share/tmux/layouts/$1
|
||||
if [[ "$2" != "" ]]; then
|
||||
tmux rename-window $2
|
||||
fi
|
||||
|
||||
@@ -19,8 +19,8 @@ prompt_fresh_setup() {
|
||||
autoload -U add-zsh-hook
|
||||
|
||||
# Hook to print the first line of the "two line" prompt, this line is not
|
||||
# actually part of the prompt so does not get redrawn which can sometimes
|
||||
# cause lines before the prompt to disappear.
|
||||
# actually part of the prompt so does not get redrawn, this is preferable
|
||||
# since sometimes lines before the prompt can disappear.
|
||||
add-zsh-hook precmd fresh_line_one
|
||||
|
||||
if [ $almostontop -eq 1 ]; then
|
||||
@@ -31,24 +31,22 @@ prompt_fresh_setup() {
|
||||
add-zsh-hook -d preexec fresh_almostontop
|
||||
fi
|
||||
|
||||
if [ "$USERNAME" = "root" ]; then
|
||||
local user="%{%F{9}%}%n%{%f%}"
|
||||
if [ "$USER" = "root" ]; then
|
||||
local user="%{%F{1}%}%n%{%f%}"
|
||||
else
|
||||
local user="%{%F{35}%}%n%{%f%}"
|
||||
fi
|
||||
|
||||
local userhost=$USER
|
||||
if [ "$SSH_CONNECTION" != "" ]; then
|
||||
local user="%{%F{35}%}$user%{%f%}@%{%F{244}%}%M%{%f%}"
|
||||
local user="$user@%{%F{244}%}%M%{%f%}"
|
||||
local userhost="$userhost@`hostname`"
|
||||
fi
|
||||
|
||||
local length=`fresh_visible_length "$user"`
|
||||
|
||||
PS1="«$user» "
|
||||
PS2="${(l:$length + 1:: :)}» "
|
||||
PS2="«${(l:${#userhost}:: :)}» "
|
||||
|
||||
RPS1='$(fresh_rprompt)'
|
||||
|
||||
prompt_opts=(cr percent sp subst)
|
||||
prompt_opts=(percent sp subst)
|
||||
}
|
||||
|
||||
prompt_cleanup() {
|
||||
@@ -61,6 +59,8 @@ fresh_line_one() {
|
||||
|
||||
# Construct the time and directory portions of the prompt
|
||||
local time_stamp="%{%F{244}%}%D{%H:%M:%S}%{%f%}"
|
||||
[[ -n $SANDBOX_HOME ]] && \
|
||||
local directory="%{%F{3}%}$SANDBOX_NAME${PWD#$SANDBOX_HOME}%{%f%}" || \
|
||||
local directory="%{%F{37}%}%~%{%f%}"
|
||||
|
||||
# Check we are in a git repository
|
||||
@@ -87,7 +87,7 @@ fresh_line_one() {
|
||||
fi
|
||||
|
||||
# Construct the git prompt
|
||||
local git="%{%F{66}%}$branch%{%f%}$ahead$behind "
|
||||
local git=" %{%F{66}%}$branch%{%f%}$ahead$behind "
|
||||
|
||||
if [ -f ~/.cache/zsh/git-prompt ]; then
|
||||
# Get the change counts from git-prompt
|
||||
@@ -117,29 +117,23 @@ fresh_line_one() {
|
||||
fi
|
||||
fi
|
||||
|
||||
# Construct the prompt string
|
||||
local line="$time_stamp $directory $git"
|
||||
# If the last command failed, display its error code at the right
|
||||
if [[ $exit_code -ne 0 ]]; then
|
||||
local result=" %{%B%F{1}%}$exit_code%{%f%b%}"
|
||||
fi
|
||||
|
||||
# If a virtualenv is enabled, display it's basename
|
||||
if [[ ! -z "$VIRTUAL_ENV" ]]; then
|
||||
py=" %{%F{4}%}py%{%f%}%{%F{3}%}$(basename $VIRTUAL_ENV)%{%f%}"
|
||||
fi
|
||||
|
||||
# If docker-machine env is active, display the machines name
|
||||
if [[ ! -z "$DOCKER_MACHINE_NAME" ]]; then
|
||||
docker=" %{%F{6}%}$DOCKER_MACHINE_NAME%{%f%}"
|
||||
fi
|
||||
|
||||
# Print the first line of the prompt
|
||||
if [[ $exit_code -eq 0 ]]; then
|
||||
print -P "$line"
|
||||
else
|
||||
# The last command failed, display its error code at the right
|
||||
local result="%{%B%F{1}%}$exit_code%{%f%b%}"
|
||||
local length=`fresh_visible_length "$line$result"`
|
||||
print -P "$line${(l:COLUMNS - $length - 1:: :)}$result"
|
||||
fi
|
||||
}
|
||||
|
||||
fresh_rprompt() {
|
||||
rprompt=""
|
||||
if [[ ! -z "$DOCKER_MACHINE_NAME" ]]; then
|
||||
rprompt="$rprompt %{%F{3}%}$DOCKER_MACHINE_NAME%{%f%}"
|
||||
fi
|
||||
if [[ ! -z "$VIRTUAL_ENV" ]]; then
|
||||
rprompt="$rprompt %{%F{3}%}$(basename $VIRTUAL_ENV)%{%f%}"
|
||||
fi
|
||||
echo $rprompt
|
||||
print -P "$time_stamp $directory$git$py$docker$result"
|
||||
}
|
||||
|
||||
fresh_almostontop() {
|
||||
@@ -148,15 +142,10 @@ fresh_almostontop() {
|
||||
print -P "$PROMPT"'$1'
|
||||
}
|
||||
|
||||
fresh_visible_length() {
|
||||
echo $(( ${#${(S%%)1//(\%(KF1]|)\{*\}|\%[Bbkf])}} ))
|
||||
}
|
||||
|
||||
fresh_compile_git_prompt() {
|
||||
# Compile a simple C executable which parses the output of `git status
|
||||
# --procelain` to greatly decrease the time taken to render the prompt
|
||||
local cache=~/.cache/zsh
|
||||
if [ ! -d $cache ]; then mkdir -p $cache; fi
|
||||
# Compile a simple C program which parses the output of `git status
|
||||
# --procelain` to greatly decrease the time taken to draw the prompt
|
||||
local cache=~/.cache/zsh; [ ! -d $cache ] && mkdir -p $cache
|
||||
if [ ! -f $cache/git-prompt ]; then
|
||||
cc -x c -std=gnu99 -O3 -DNDEBUG -o $cache/git-prompt - 2> /dev/null << EOF
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
if [[ "" == $SANDBOX_ENV_IN_FILE ]]; then
|
||||
export SANDBOX_ENV_IN_FILE=$AUTOENV_IN_FILE
|
||||
fi
|
||||
if [[ "" == $SANDBOX_ENV_OUT_FILE ]]; then
|
||||
export SANDBOX_ENV_OUT_FILE=$AUTOENV_OUT_FILE
|
||||
fi
|
||||
if [[ "" == $SANDBOX_ROOT ]]; then
|
||||
export SANDBOX_ROOT=$HOME/Sandbox
|
||||
fi
|
||||
@@ -33,11 +27,11 @@ sandbox() {
|
||||
begin=$PWD
|
||||
cd $sandbox
|
||||
|
||||
echo "SANDBOX_HOME=\$(dirname -- "\$0:a")" >> $SANDBOX_ENV_IN_FILE
|
||||
echo "SANDBOX_NAME=$2" >> $SANDBOX_ENV_IN_FILE
|
||||
echo "SANDBOX_HOME=\$(dirname -- "\$0:a")" >> .enter
|
||||
echo "SANDBOX_NAME=$2" >> .enter
|
||||
|
||||
echo "unset SANDBOX_NAME" >> $SANDBOX_ENV_OUT_FILE
|
||||
echo "unset SANDBOX_HOME" >> $SANDBOX_ENV_OUT_FILE
|
||||
echo "unset SANDBOX_NAME" >> .exit
|
||||
echo "unset SANDBOX_HOME" >> .exit
|
||||
|
||||
git init &> /dev/null
|
||||
|
||||
|
||||
5
zprofile
5
zprofile
@@ -1,2 +1,7 @@
|
||||
# .zprofile [1] Used for executing user's commands at start, will be sourced
|
||||
# when starting as a login shell.
|
||||
|
||||
# macOS is obnoxious and overwrites the PATH from a users ~/.zshenv, which is
|
||||
# sourced first, in /etc/zprofile by calling `/usr/libexec/path_helper -s` so
|
||||
# this is required so that PATH is once again set to the desired value.
|
||||
[ `uname` = Darwin ] && source ~/.zshenv
|
||||
|
||||
22
zshenv
22
zshenv
@@ -5,22 +5,32 @@
|
||||
# Enable saving command history to file
|
||||
[ ! -d $HOME/.cache/zsh ] && mkdir -p $HOME/.cache/zsh
|
||||
HISTFILE=$HOME/.cache/zsh/histfile
|
||||
HISTSIZE=5000
|
||||
SAVEHIST=5000
|
||||
HISTSIZE=20000
|
||||
SAVEHIST=20000
|
||||
|
||||
# Enable time stats for long lasting commands
|
||||
REPORTTIME=5
|
||||
|
||||
# Add Homebrew python to PATH on macOS if present
|
||||
[ "`uname`" = "Darwin" ] && [ -d /usr/local/opt/python/libexec/bin ] &&
|
||||
PATH=/usr/local/opt/python/libexec/bin:$PATH
|
||||
|
||||
# Add ~/.local to the environment
|
||||
fpath+=$HOME/.local/share/zsh/site-functions
|
||||
PATH=$HOME/.local/bin:$PATH
|
||||
MANPATH=$HOME/.local/share/man:$MANPATH
|
||||
INFOPATH=$HOME/.local/share/info:$INFOPATH
|
||||
|
||||
if [ `uname` = Darwin ]; then
|
||||
[ -f /usr/local/bin/ccache ] && \
|
||||
PATH=/usr/local/opt/ccache/libexec:$PATH
|
||||
else
|
||||
[ -f /usr/bin/ccache ] && \
|
||||
PATH=/usr/lib/ccache:$PATH
|
||||
fi
|
||||
|
||||
# Remove duplicates from environment variables
|
||||
typeset -U fpath
|
||||
typeset -U PATH; export PATH
|
||||
typeset -U MANPATH; export MANPATH
|
||||
typeset -U INFOPATH; export INFOPATH
|
||||
|
||||
# Use ~/.local for pip installs on macOS
|
||||
[ "`uname`" = "Darwin" ] && export PYTHONUSERBASE=$HOME/.local
|
||||
|
||||
|
||||
34
zshrc
34
zshrc
@@ -32,18 +32,19 @@ source-plugin build
|
||||
source-plugin sandbox
|
||||
|
||||
# Layout tmux window commands
|
||||
source-plugin layout
|
||||
[ "$TMUX" != "" ] && source-plugin layout
|
||||
|
||||
# Note taking commands
|
||||
source-plugin notes
|
||||
|
||||
# Remove duplicates from history
|
||||
setopt hist_ignore_all_dups
|
||||
setopt hist_reduce_blanks
|
||||
setopt hist_save_no_dups
|
||||
setopt histignoredups
|
||||
|
||||
# Enable multi-terminal history
|
||||
setopt inc_append_history
|
||||
setopt share_history
|
||||
|
||||
# Disable error when no glob matches are found
|
||||
setopt nonomatch
|
||||
|
||||
# Enable comments in the prompt
|
||||
setopt interactive_comments
|
||||
@@ -52,10 +53,13 @@ setopt interactive_comments
|
||||
setopt ignore_eof
|
||||
|
||||
# Disable sound
|
||||
unsetopt beep
|
||||
setopt nobeep
|
||||
|
||||
# Disable tty flow control, allows vim to use '<Ctrl>S'
|
||||
unsetopt flow_control && stty -ixon
|
||||
setopt noflowcontrol
|
||||
|
||||
# Enable completions in the middle of a word
|
||||
setopt completeinword
|
||||
|
||||
# Initialize completions
|
||||
autoload -U compinit
|
||||
@@ -158,22 +162,6 @@ fi
|
||||
# Load work related config
|
||||
[ -f ~/.config/work/zshrc ] && source ~/.config/work/zshrc
|
||||
|
||||
# Remove duplicates from environment variables
|
||||
typeset -U PATH
|
||||
typeset -U MANPATH
|
||||
typeset -U INFOPATH
|
||||
|
||||
# Add ccache symlink directory to start of PATH, this must be after
|
||||
# `typeset -U PATH` because on macOS this reorders the list so ccache's
|
||||
# symlinks will no longer be at the start of PATH rendering it unusable.
|
||||
if [ `uname` = Darwin ]; then
|
||||
[ -f /usr/local/bin/ccache ] && \
|
||||
PATH=/usr/local/opt/ccache/libexec:$PATH
|
||||
else
|
||||
[ -f /usr/bin/ccache ] && \
|
||||
PATH=/usr/lib/ccache:$PATH
|
||||
fi
|
||||
|
||||
# Aliases
|
||||
alias grep='grep --color=always'
|
||||
which cmake &> /dev/null && \
|
||||
|
||||
Reference in New Issue
Block a user