migrate to zsh
This commit is contained in:
parent
7cc6d5508c
commit
5f705bd2ef
|
@ -22,3 +22,6 @@ alias nyan="telnet nyancat.dakko.us"
|
||||||
# Add an "alert" alias for long running commands. Use like so:
|
# Add an "alert" alias for long running commands. Use like so:
|
||||||
# sleep 10; alert
|
# sleep 10; alert
|
||||||
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
|
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
|
||||||
|
|
||||||
|
# Docker & Docker Compose
|
||||||
|
alias dc="docker-compose"
|
126
.bash_prompt
126
.bash_prompt
|
@ -1,126 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
#
|
|
||||||
# taken from https://github.com/kremalicious/dotfiles/blob/master/bash_prompt
|
|
||||||
#
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
|
||||||
# bash_prompt, from @mathiasbynens
|
|
||||||
# slightly modified
|
|
||||||
# https://github.com/mathiasbynens/dotfiles/blob/master/.bash_prompt
|
|
||||||
# ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
|
|
||||||
export TERM='gnome-256color';
|
|
||||||
elif infocmp xterm-256color >/dev/null 2>&1; then
|
|
||||||
export TERM='xterm-256color';
|
|
||||||
fi;
|
|
||||||
|
|
||||||
prompt_git() {
|
|
||||||
local s='';
|
|
||||||
local branchName='';
|
|
||||||
|
|
||||||
# Check if the current directory is in a Git repository.
|
|
||||||
if [ $(git rev-parse --is-inside-work-tree &>/dev/null; echo "${?}") == '0' ]; then
|
|
||||||
|
|
||||||
# check if the current directory is in .git before running git checks
|
|
||||||
if [ "$(git rev-parse --is-inside-git-dir 2> /dev/null)" == 'false' ]; then
|
|
||||||
|
|
||||||
# Ensure the index is up to date.
|
|
||||||
git update-index --really-refresh -q &>/dev/null;
|
|
||||||
|
|
||||||
# Check for uncommitted changes in the index.
|
|
||||||
if ! $(git diff --quiet --ignore-submodules --cached); then
|
|
||||||
s+='+';
|
|
||||||
fi;
|
|
||||||
|
|
||||||
# Check for unstaged changes.
|
|
||||||
if ! $(git diff-files --quiet --ignore-submodules --); then
|
|
||||||
s+='!';
|
|
||||||
fi;
|
|
||||||
|
|
||||||
# Check for untracked files.
|
|
||||||
if [ -n "$(git ls-files --others --exclude-standard)" ]; then
|
|
||||||
s+='?';
|
|
||||||
fi;
|
|
||||||
|
|
||||||
# Check for stashed files.
|
|
||||||
if $(git rev-parse --verify refs/stash &>/dev/null); then
|
|
||||||
s+='$';
|
|
||||||
fi;
|
|
||||||
|
|
||||||
fi;
|
|
||||||
|
|
||||||
# Get the short symbolic ref.
|
|
||||||
# If HEAD isn’t a symbolic ref, get the short SHA for the latest commit
|
|
||||||
# Otherwise, just give up.
|
|
||||||
branchName="$(git symbolic-ref --quiet --short HEAD 2> /dev/null || \
|
|
||||||
git rev-parse --short HEAD 2> /dev/null || \
|
|
||||||
echo '(unknown)')";
|
|
||||||
|
|
||||||
[ -n "${s}" ] && s=" ${s}";
|
|
||||||
|
|
||||||
echo -e "${1}${branchName}${orange}${s}";
|
|
||||||
else
|
|
||||||
return;
|
|
||||||
fi;
|
|
||||||
}
|
|
||||||
|
|
||||||
if tput setaf 1 &> /dev/null; then
|
|
||||||
tput sgr0; # reset colors
|
|
||||||
bold=$(tput bold);
|
|
||||||
dim=$(tput setaf 240);
|
|
||||||
reset=$(tput sgr0);
|
|
||||||
# Tomorrow colors, taken from https://github.com/Slava/vim-colors-tomorrow/blob/master/colors/tomorrow.vim
|
|
||||||
black=$(tput setaf 236);
|
|
||||||
gray=$(tput setaf 242);
|
|
||||||
blue=$(tput setaf 109);
|
|
||||||
green=$(tput setaf 143);
|
|
||||||
cyan=$(tput setaf 43);
|
|
||||||
orange=$(tput setaf 173);
|
|
||||||
purple=$(tput setaf 125);
|
|
||||||
red=$(tput setaf 167);
|
|
||||||
magenta=$(tput setaf 139);
|
|
||||||
violet=$(tput setaf 139);
|
|
||||||
white=$(tput setaf 15);
|
|
||||||
yellow=$(tput setaf 136);
|
|
||||||
else
|
|
||||||
bold='';
|
|
||||||
reset="\e[0m";
|
|
||||||
black="\e[1;30m";
|
|
||||||
blue="\e[1;34m";
|
|
||||||
cyan="\e[1;36m";
|
|
||||||
green="\e[1;32m";
|
|
||||||
orange="\e[1;33m";
|
|
||||||
purple="\e[1;35m";
|
|
||||||
red="\e[1;31m";
|
|
||||||
violet="\e[1;35m";
|
|
||||||
white="\e[1;37m";
|
|
||||||
yellow="\e[1;33m";
|
|
||||||
fi;
|
|
||||||
|
|
||||||
# Highlight the user name when logged in as root.
|
|
||||||
if [[ "${USER}" == "root" ]]; then
|
|
||||||
userStyle="${red}";
|
|
||||||
else
|
|
||||||
userStyle="${gray}";
|
|
||||||
fi;
|
|
||||||
|
|
||||||
if [[ "${SSH_TTY}" ]]; then
|
|
||||||
PS1="\[\033]0;\W • \h\007\]"; # Set the terminal title
|
|
||||||
PS1+="\n";
|
|
||||||
PS1+="\[${userStyle}\]\u "; # username
|
|
||||||
PS1+="\[${orange}\]\h \[${reset}\]"; # host
|
|
||||||
else
|
|
||||||
PS1="\[\033]0;\W\007\]"; # Set the terminal title
|
|
||||||
PS1+="\n";
|
|
||||||
fi;
|
|
||||||
|
|
||||||
PS1+="\[${cyan}\]\w"; # working directory full path
|
|
||||||
PS1+="\$(prompt_git \" \[${gray}\]\")"; # Git repository details
|
|
||||||
PS1+="\n";
|
|
||||||
PS1+="\[${white}\]→ \[${reset}\]"; # `→` (and reset color)
|
|
||||||
export PS1;
|
|
||||||
|
|
||||||
PS2="\[${white}\]→ \[${reset}\]";
|
|
||||||
export PS2;
|
|
94
.bashrc
94
.bashrc
|
@ -1,94 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# If not running interactively, don't do anything
|
|
||||||
case $- in
|
|
||||||
*i*) ;;
|
|
||||||
*) return;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
|
||||||
# SHELL OPTIONS
|
|
||||||
# ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
# Append to the Bash history file, rather than overwriting it
|
|
||||||
shopt -s histappend
|
|
||||||
|
|
||||||
# Save multi-line commands as one command
|
|
||||||
shopt -s cmdhist
|
|
||||||
|
|
||||||
# Avoid duplicate entries
|
|
||||||
HISTCONTROL="erasedups:ignoreboth"
|
|
||||||
|
|
||||||
# Don't record some commands
|
|
||||||
export HISTIGNORE="&:[ ]*:exit:ls:bg:fg:history:clear"
|
|
||||||
|
|
||||||
# fuck that you have new mail shit
|
|
||||||
unset MAILCHECK
|
|
||||||
|
|
||||||
# Case-insensitive globbing (used in pathname expansion)
|
|
||||||
shopt -s nocaseglob
|
|
||||||
|
|
||||||
# Turn on recursive globbing (enables ** to recurse all directories)
|
|
||||||
shopt -s globstar 2> /dev/null
|
|
||||||
|
|
||||||
# Prepend cd to directory names automatically
|
|
||||||
shopt -s autocd 2> /dev/null
|
|
||||||
|
|
||||||
# Correct spelling errors during tab-completion
|
|
||||||
shopt -s dirspell 2> /dev/null
|
|
||||||
|
|
||||||
# Correct spelling errors in arguments supplied to cd
|
|
||||||
shopt -s cdspell 2> /dev/null
|
|
||||||
|
|
||||||
# Update window size after every command
|
|
||||||
shopt -s checkwinsize
|
|
||||||
|
|
||||||
# Automatically trim long paths in the prompt (requires Bash 4.x)
|
|
||||||
PROMPT_DIRTRIM=4
|
|
||||||
|
|
||||||
# Perform file completion in a case insensitive fashion
|
|
||||||
bind "set completion-ignore-case on"
|
|
||||||
|
|
||||||
# Treat hyphens and underscores as equivalent
|
|
||||||
bind "set completion-map-case on"
|
|
||||||
|
|
||||||
# Display matches for ambiguous patterns at first tab press
|
|
||||||
bind "set show-all-if-ambiguous on"
|
|
||||||
|
|
||||||
# Immediately add a trailing slash when autocompleting symlinks to directories
|
|
||||||
bind "set mark-symlinked-directories on"
|
|
||||||
|
|
||||||
# enable programmable completion features (you don't need to enable
|
|
||||||
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
|
|
||||||
# sources /etc/bash.bashrc).
|
|
||||||
if ! shopt -oq posix; then
|
|
||||||
if [ -f /usr/share/bash-completion/bash_completion ]; then
|
|
||||||
. /usr/share/bash-completion/bash_completion
|
|
||||||
elif [ -f /etc/bash_completion ]; then
|
|
||||||
. /etc/bash_completion
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# LSCOLORS
|
|
||||||
export CLICOLOR=1
|
|
||||||
export LSCOLORS=gxfxcxdxbxegedabagacad
|
|
||||||
|
|
||||||
# enable color support of ls and also add handy aliases
|
|
||||||
if [ -x /usr/bin/dircolors ]; then
|
|
||||||
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
|
|
||||||
alias ls='ls --color=auto'
|
|
||||||
#alias dir='dir --color=auto'
|
|
||||||
#alias vdir='vdir --color=auto'
|
|
||||||
|
|
||||||
alias grep='grep --color=auto'
|
|
||||||
alias fgrep='fgrep --color=auto'
|
|
||||||
alias egrep='egrep --color=auto'
|
|
||||||
fi
|
|
||||||
|
|
||||||
export NPM_PACKAGES="$HOME/.npm-packages"
|
|
||||||
export NODE_PATH="$NPM_PACKAGES/lib/node_modules${NODE_PATH:+:$NODE_PATH}"
|
|
||||||
export PATH="$NPM_PACKAGES/bin:$PATH"
|
|
||||||
# Unset manpath so we can inherit from /etc/manpath via the `manpath`
|
|
||||||
# command
|
|
||||||
unset MANPATH # delete if you already modified MANPATH elsewhere in your config
|
|
||||||
export MANPATH="$NPM_PACKAGES/share/man:$(manpath)"
|
|
29
.exports
Normal file
29
.exports
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Set architecture flags
|
||||||
|
export ARCHFLAGS="-arch x86_64"
|
||||||
|
|
||||||
|
# Prefer US English and use UTF-8
|
||||||
|
export LC_ALL="en_US.UTF-8"
|
||||||
|
export LANG="en_US"
|
||||||
|
|
||||||
|
# ---------------------------------------------------
|
||||||
|
# PATH
|
||||||
|
# ---------------------------------------------------
|
||||||
|
|
||||||
|
export NPM_PACKAGES=$HOME/.npm-packages
|
||||||
|
export NODE_PATH="$NPM_PACKAGES/lib/node_modules${NODE_PATH:+:$NODE_PATH}"
|
||||||
|
export PATH=$HOME/bin:/usr/local/bin:$NPM_PACKAGES/bin:$PATH
|
||||||
|
|
||||||
|
# define CDPATHs which are autocompleted from when doing cd
|
||||||
|
export CDPATH=$CDPATH:~/Code
|
||||||
|
|
||||||
|
# Unset manpath so we can inherit from /etc/manpath via the `manpath`
|
||||||
|
# command
|
||||||
|
unset MANPATH # delete if you already modified MANPATH elsewhere in your config
|
||||||
|
export MANPATH="$NPM_PACKAGES/share/man:$(manpath)"
|
||||||
|
|
||||||
|
# pip should only run if there is a virtualenv currently activated
|
||||||
|
#export PIP_REQUIRE_VIRTUALENV=true
|
||||||
|
# cache pip-installed packages to avoid re-downloading
|
||||||
|
export PIP_DOWNLOAD_CACHE=$HOME/.pip/cache
|
20
.profile
20
.profile
|
@ -1,20 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# if running bash
|
|
||||||
if [ -n "$BASH_VERSION" ]; then
|
|
||||||
|
|
||||||
# source all the things
|
|
||||||
for file in ~/.{bashrc,bash_prompt,bash_aliases,private}; do
|
|
||||||
[ -r "$file" ] && [ -f "$file" ] && source "$file"
|
|
||||||
done;
|
|
||||||
unset file;
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
# set PATH so it includes user's private bin if it exists
|
|
||||||
if [ -d "$HOME/bin" ] ; then
|
|
||||||
PATH="$HOME/bin:$PATH"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# define CDPATHs which are autocompleted from when doing cd
|
|
||||||
export CDPATH=$CDPATH:~/code
|
|
78
.zshrc
Normal file
78
.zshrc
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
# zmodload zsh/zprof
|
||||||
|
|
||||||
|
# https://github.com/sindresorhus/pure
|
||||||
|
autoload -U promptinit; promptinit
|
||||||
|
PURE_GIT_DOWN_ARROW=↓
|
||||||
|
PURE_GIT_UP_ARROW=↑
|
||||||
|
prompt pure
|
||||||
|
|
||||||
|
CASE_SENSITIVE="true"
|
||||||
|
DISABLE_UPDATE_PROMPT="true"
|
||||||
|
DISABLE_AUTO_TITLE="true"
|
||||||
|
ENABLE_CORRECTION="true"
|
||||||
|
|
||||||
|
# History
|
||||||
|
[ -z "$HISTFILE" ] && HISTFILE="$HOME/.zsh_history"
|
||||||
|
HIST_STAMPS="yyyy-mm-dd"
|
||||||
|
HISTSIZE=50000
|
||||||
|
SAVEHIST=10000
|
||||||
|
setopt extended_history
|
||||||
|
setopt hist_expire_dups_first
|
||||||
|
setopt hist_ignore_dups
|
||||||
|
setopt hist_ignore_space
|
||||||
|
setopt inc_append_history
|
||||||
|
setopt share_history
|
||||||
|
|
||||||
|
# Changing directories
|
||||||
|
setopt auto_cd
|
||||||
|
setopt auto_pushd
|
||||||
|
unsetopt pushd_ignore_dups
|
||||||
|
setopt pushdminus
|
||||||
|
|
||||||
|
# Completion
|
||||||
|
setopt auto_menu
|
||||||
|
setopt always_to_end
|
||||||
|
setopt complete_in_word
|
||||||
|
unsetopt flow_control
|
||||||
|
unsetopt menu_complete
|
||||||
|
zstyle ':completion:*:*:*:*:*' menu select
|
||||||
|
zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|=*' 'l:|=* r:|=*'
|
||||||
|
zstyle ':completion::complete:*' use-cache 1
|
||||||
|
zstyle ':completion::complete:*' cache-path $ZSH_CACHE_DIR
|
||||||
|
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
|
||||||
|
|
||||||
|
# Highlight the current autocomplete option
|
||||||
|
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
|
||||||
|
|
||||||
|
# Better SSH/SCP/Rsync Autocomplete
|
||||||
|
h=()
|
||||||
|
if [[ -r ~/.ssh/config ]]; then
|
||||||
|
h=($h ${${${(@M)${(f)"$(cat ~/.ssh/config)"}:#Host *}#Host }:#*[*?]*})
|
||||||
|
fi
|
||||||
|
if [[ -r ~/.ssh/known_hosts ]]; then
|
||||||
|
h=($h ${${${(f)"$(cat ~/.ssh/known_hosts{,2} || true)"}%%\ *}%%,*}) 2>/dev/null
|
||||||
|
fi
|
||||||
|
if [[ $#h -gt 0 ]]; then
|
||||||
|
zstyle ':completion:*:(ssh|scp|rsync|slogin):*' hosts $h
|
||||||
|
fi
|
||||||
|
|
||||||
|
# https://gist.github.com/ctechols/ca1035271ad134841284#gistcomment-2767420
|
||||||
|
autoload -Uz compinit
|
||||||
|
if [[ -n ~/.zcompdump(#qN.mh+24) ]]; then
|
||||||
|
compinit
|
||||||
|
touch ~/.zcompdump
|
||||||
|
else
|
||||||
|
compinit -C
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Other
|
||||||
|
setopt prompt_subst
|
||||||
|
|
||||||
|
# User configuration
|
||||||
|
source ~/.exports
|
||||||
|
source ~/.aliases
|
||||||
|
source ~/.private
|
||||||
|
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
||||||
|
source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh
|
||||||
|
|
||||||
|
# zprof
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# list of files/folders to symlink in homedir
|
# list of files/folders to symlink in homedir
|
||||||
FILES=".bash_aliases .bash_prompt .bashrc .profile bin .vimrc .npmrc"
|
FILES="bin .aliases .exports .npmrc .vimrc .zshrc"
|
||||||
|
|
||||||
for FILE in $FILES; do
|
for FILE in $FILES; do
|
||||||
|
|
||||||
|
@ -17,7 +17,3 @@ for FILE in $FILES; do
|
||||||
echo "$(tput setaf 64)✓$(tput sgr0) Symlink created to $(tput setaf 37)$FILE$(tput sgr0)"
|
echo "$(tput setaf 64)✓$(tput sgr0) Symlink created to $(tput setaf 37)$FILE$(tput sgr0)"
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# source what we just created
|
|
||||||
# shellcheck disable=SC1090
|
|
||||||
source "$HOME"/.profile
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user