rewrote zsh dotfile in my own style.

This commit is contained in:
Gabe Venberg 2020-05-29 17:24:53 -05:00
parent 4873ff9e5c
commit baa1ff01ce
4 changed files with 130 additions and 460 deletions

View file

@ -1,218 +0,0 @@
# Configuration file for dircolors, a utility to help you set the
# LS_COLORS environment variable used by GNU ls with the --color option.
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
# Copying and distribution of this file, with or without modification,
# are permitted provided the copyright notice and this notice are preserved.
# The keywords COLOR, OPTIONS, and EIGHTBIT (honored by the
# slackware version of dircolors) are recognized but ignored.
# Below, there should be one TERM entry for each termtype that is colorizable
TERM Eterm
TERM ansi
TERM color-xterm
TERM con132x25
TERM con132x30
TERM con132x43
TERM con132x60
TERM con80x25
TERM con80x28
TERM con80x30
TERM con80x43
TERM con80x50
TERM con80x60
TERM cons25
TERM console
TERM cygwin
TERM dtterm
TERM eterm-color
TERM gnome
TERM gnome-256color
TERM hurd
TERM jfbterm
TERM konsole
TERM kterm
TERM linux
TERM linux-c
TERM mach-color
TERM mach-gnu-color
TERM mlterm
TERM putty
TERM putty-256color
TERM rxvt
TERM rxvt-256color
TERM rxvt-cygwin
TERM rxvt-cygwin-native
TERM rxvt-unicode
TERM rxvt-unicode-256color
TERM rxvt-unicode256
TERM screen
TERM screen.xterm-256color
TERM screen-256color
TERM screen-256color-bce
TERM screen-bce
TERM screen-w
TERM screen.Eterm
TERM screen.rxvt
TERM screen.linux
TERM st
TERM st-256color
TERM terminator
TERM vt100
TERM xterm
TERM xterm-16color
TERM xterm-256color
TERM xterm-88color
TERM xterm-color
TERM xterm-debian
# Below are the color init strings for the basic file types. A color init
# string consists of one or more of the following numeric codes:
# Attribute codes:
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
# Text color codes:
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
# Background color codes:
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
#NORMAL 00 # no color code at all
#FILE 00 # regular file: use no color at all
RESET 0 # reset to "normal" color
DIR 01;34 # directory
LINK target #01;36 # symbolic link. (If you set this to 'target' instead of a
# numerical value, the color is as for the file pointed to.)
MULTIHARDLINK 00 # regular file with more than one link
FIFO 40;33 # pipe
SOCK 01;35 # socket
DOOR 01;35 # door
BLK 40;33;01 # block device driver
CHR 40;33;01 # character device driver
ORPHAN 40;31;01 # symlink to nonexistent file, or non-stat'able file
SETUID 37;41 # file that is setuid (u+s)
SETGID 30;43 # file that is setgid (g+s)
CAPABILITY 30;41 # file with capability
STICKY_OTHER_WRITABLE 37;41 # dir that is sticky and other-writable (+t,o+w)
OTHER_WRITABLE 31;40 # dir that is other-writable (o+w) and not sticky
STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable
# This is for files with execute permission:
EXEC 01;32
# List any file extensions like '.gz' or '.tar' that you would like ls
# to colorize below. Put the extension, a space, and the color init string.
# (and any comments you want to add after a '#')
# If you use DOS-style suffixes, you may want to uncomment the following:
#.cmd 01;32 # executables (bright green)
#.exe 01;32
#.com 01;32
#.btm 01;32
#.bat 01;32
# Or if you want to colorize scripts even if they do not have the
# executable bit actually set.
#.sh 01;32
#.csh 01;32
# archives or compressed (bright red)
.tar 01;31
.tgz 01;31
.arc 01;31
.arj 01;31
.taz 01;31
.lha 01;31
.lz4 01;31
.lzh 01;31
.lzma 01;31
.tlz 01;31
.txz 01;31
.tzo 01;31
.t7z 01;31
.zip 01;31
.z 01;31
.Z 01;31
.dz 01;31
.gz 01;31
.lrz 01;31
.lz 01;31
.lzo 01;31
.xz 01;31
.bz2 01;31
.bz 01;31
.tbz 01;31
.tbz2 01;31
.tz 01;31
.deb 01;31
.rpm 01;31
.jar 01;31
.war 01;31
.ear 01;31
.sar 01;31
.rar 01;31
.alz 01;31
.ace 01;31
.zoo 01;31
.cpio 01;31
.7z 01;31
.rz 01;31
.cab 01;31
# image formats
.jpg 01;35
.jpeg 01;35
.gif 01;35
.bmp 01;35
.pbm 01;35
.pgm 01;35
.ppm 01;35
.tga 01;35
.xbm 01;35
.xpm 01;35
.tif 01;35
.tiff 01;35
.png 01;35
.svg 01;35
.svgz 01;35
.mng 01;35
.pcx 01;35
.mov 01;35
.mpg 01;35
.mpeg 01;35
.m2v 01;35
.mkv 01;35
.webm 01;35
.ogm 01;35
.mp4 01;35
.m4v 01;35
.mp4v 01;35
.vob 01;35
.qt 01;35
.nuv 01;35
.wmv 01;35
.asf 01;35
.rm 01;35
.rmvb 01;35
.flc 01;35
.avi 01;35
.fli 01;35
.flv 01;35
.gl 01;35
.dl 01;35
.xcf 01;35
.xwd 01;35
.yuv 01;35
.cgm 01;35
.emf 01;35
# http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions
.axv 01;35
.anx 01;35
.ogv 01;35
.ogx 01;35
# audio formats
.aac 00;36
.au 00;36
.flac 00;36
.m4a 00;36
.mid 00;36
.midi 00;36
.mka 00;36
.mp3 00;36
.mpc 00;36
.ogg 00;36
.ra 00;36
.wav 00;36
# http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions
.axa 00;36
.oga 00;36
.spx 00;36
.xspf 00;36

View file

@ -1,86 +0,0 @@
#Copyright 2018 TheToric
#
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program. If not, see <http://www.gnu.org/licenses/>.
# intellegently extract archives based on extension.
# web_search from terminal
function web_search() {
emulate -L zsh
# define search engine URLS
typeset -A urls
urls=(
ddg "https://www.duckduckgo.com/?q="
github "https://github.com/search?q="
)
# check whether the search engine is supported
if [[ -z "$urls[$1]" ]]; then
echo "Search engine $1 not supported."
return 1
fi
# search or go to main page depending on number of arguments passed
if [[ $# -gt 1 ]]; then
# build search url:
# join arguments passed with '+', then append to search engine URL
url="${urls[$1]}${(j:+:)@[2,-1]}"
else
# build main page url:
# split by '/', then rejoin protocol (1) and domain (2) parts with '//'
url="${(j://:)${(s:/:)urls[$1]}[1,2]}"
fi
open_command "$url"
}
#use generalized open command
function open_command() {
emulate -L zsh
setopt shwordsplit
local open_cmd
# define the open command
case "$OSTYPE" in
darwin*) open_cmd='open' ;;
cygwin*) open_cmd='cygstart' ;;
linux*) open_cmd='xdg-open' ;;
msys*) open_cmd='start ""' ;;
*) echo "Platform $OSTYPE not supported"
return 1
;;
esac
# don't use nohup on OSX
if [[ "$OSTYPE" == darwin* ]]; then
$open_cmd "$@" &>/dev/null
else
nohup $open_cmd "$@" &>/dev/null
fi
}
# Show dots while waiting for tab-completion
expand-or-complete-with-dots() {
# toggle line-wrapping off and back on again
[[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti rmam
print -Pn "%{%F{red}......%f%}"
[[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti smam
zle expand-or-complete
zle redisplay
}
zle -N expand-or-complete-with-dots
bindkey "^I" expand-or-complete-with-dots

View file

@ -1,48 +0,0 @@
#This file is to set up the ZSH prompt. This is a customized prompt, and, as will all my zsh things, does not rely on an outside plugin.
#Also like most of my stuff, mutch of this code is taken from another source. in this case, I used the GRML zshrc as a base.
#Copyright 2018 TheToric
#
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program. If not, see <http://www.gnu.org/licenses/>.
#this is a WIP.
#TODO: make this a proper prompt theme file instead of just a sourced file... maybye.
autoload -U promptinit
promptinit
autoload -U colors
colors
#stuff to show git things.
autoload -Uz vcs_info
setopt prompt_subst
precmd_vcs() {vcs_info}
#when not in a repo, show full path to current directory. when in one, show path from base direcory of the repo.
zstyle ':vcs_info:*' nvcsformats '%~'
zstyle ':vcs_info:*' formats '%r/%S %F{green}[%b]%f'
#the precmd function, called just before printing the prompt. TODO: use this to set our prompt variable as different evey time, in order to get a right aligned portion in the top line.
function precmd() {
precmd_vcs
}
#on the top line, show a whole bunch of info. botton line should be as minimal as possilbe (just a single char to input next to...)
PROMPT='%F{cyan}[%m@%n]%f%F{red}├────┤%f${vcs_info_msg_0_}
»'
#Make the right prompt blank, just to be sure.
RPROMPT=

View file

@ -1,6 +1,3 @@
# Based off of the zshrc of Josh Hartwell, with many additions, deletions, and changes from across the outside community.
#Copyright 2018 TheToric
#
#This program is free software: you can redistribute it and/or modify #This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by #it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or #the Free Software Foundation, either version 3 of the License, or
@ -13,113 +10,156 @@
# #
#You should have received a copy of the GNU General Public License #You should have received a copy of the GNU General Public License
#along with this program. If not, see <http://www.gnu.org/licenses/>. #along with this program. If not, see <http://www.gnu.org/licenses/>.
#
local ZSH_CONF=$HOME/.config/zsh # Define the place I store all my zsh config stuff
local ZSH_CACHE=$ZSH_CONF/cache # for storing files like history and zcompdump
local LOCAL_ZSHRC=$HOME/.config/zshlocal # Allow the local machine to have its own overriding zshrc if it wants it
# Load external config files and tools #web_search from terminal
function web_search() {
emulate -L zsh
# Load misc functions. Done in a seperate file to keep this from getting too long and ugly # define search engine URLS
source $ZSH_CONF/functions.zsh typeset -A urls
#Load prompt file. Also done to keep it more tidy. urls=(
source $ZSH_CONF/prompt.zsh ddg "https://www.duckduckgo.com/?q="
github "https://github.com/search?q="
)
# Set important shell variables # check whether the search engine is supported
export EDITOR=nvim # Set default editor if [[ -z "$urls[$1]" ]]; then
export VISUAL=nvim echo "Search engine $1 not supported."
export PAGER=less # Set default pager return 1
export LESS="-R" # Set the default options for less fi
export LESSHISTFILE="/dev/null" # Prevent the less hist file from being made, I dont want it
# Misc # search or go to main page depending on number of arguments passed
if [[ $# -gt 1 ]]; then
# build search url:
# join arguments passed with '+', then append to search engine URL
url="${urls[$1]}${(j:+:)@[2,-1]}"
else
# build main page url:
# split by '/', then rejoin protocol (1) and domain (2) parts with '//'
url="${(j://:)${(s:/:)urls[$1]}[1,2]}"
fi
open_command "$url"
}
#prompt
autoload -U promptinit
promptinit
autoload -U colors
colors
#stuff to show git things.
autoload -Uz vcs_info
setopt prompt_subst
precmd_vcs() {vcs_info}
#when not in a repo, show full path to current directory. when in one, show path from base direcory of the repo.
zstyle ':vcs_info:*' nvcsformats '%~'
zstyle ':vcs_info:*' formats '%r/%S %F{green}[%b]%f'
#the precmd function, called just before printing the prompt.
function precmd() {
precmd_vcs
}
#Make the right prompt blank, just to be sure.
RPROMPT=
#on the top line, show a whole bunch of info. botton line should be as minimal as possilbe (just a single char to input next to...)
PROMPT='%F{cyan}[%m@%n]%f%F{red}├────┤%f${vcs_info_msg_0_}
»'
#show dots while waiting for tab-completion
expand-or-complete-with-dots() {
# toggle line-wrapping off and back on again
[[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti rmam
print -Pn "%{%F{red}......%f%}"
[[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti smam
zle expand-or-complete
zle redisplay
}
zle -N expand-or-complete-with-dots
bindkey "^I" expand-or-complete-with-dots
#set important shell variables
#set default editor and pager.
export EDITOR=nvim
export VISUAL=nvim
export PAGER=less
#default options for less
export LESS="-R"
export LESSHISTFILE="/dev/null"
#set the w3m homepage
export WWW_HOME="duckduckgo.com/lite/"
#misc
# Enable the ZLE line editor, which is default behavior, but to be sure # Enable the ZLE line editor, which is default behavior, but to be sure
setopt ZLE setopt ZLE
#Enable vi mode for the ZLE. it should be set by default due to our EDITOR and VISUAL, but this is just to be safe. #Enable vi mode for the ZLE. it should be set by default due to our EDITOR and VISUAL, but this is just to be safe.
bindkey -v bindkey -v
# prevent duplicate entries in path
declare -U path
# Uses custom colors for LS, as outlined in dircolors
eval $(dircolors $ZSH_CONF/dircolors)
# Sends cd commands without the need for 'cd' # Sends cd commands without the need for 'cd'
setopt AUTO_CD setopt AUTO_CD
# Can pipe to mulitple outputs
setopt MULTI_OS
# Kill all child processes when we exit, dont leave them running # Kill all child processes when we exit, dont leave them running
unsetopt NO_HUP unsetopt NO_HUP
#Allows comments in interactive shell. #Allows comments in interactive shell.
setopt INTERACTIVE_COMMENTS setopt INTERACTIVE_COMMENTS
# Abc{$cool}efg where $cool is an array surrounds all array variables individually
setopt RC_EXPAND_PARAM
# Ctrl+S and Ctrl+Q usually disable/enable tty input. This disables those inputs # Ctrl+S and Ctrl+Q usually disable/enable tty input. This disables those inputs
unsetopt FLOW_CONTROL unsetopt FLOW_CONTROL
# List jobs in the long format by default. (I dont know what this does but it sounds good) mkdir -p ~/.cache/zsh
setopt LONG_LIST_JOBS local zshCache=~/.cache/zsh
# ZSH History #ZSH history
HISTFILE=$ZSH_CACHE/history # Keep our home directory neat by keeping the histfile somewhere else #make a history file outside our home directory
SAVEHIST=10000 # Big history HISTFILE=$zshCache/history
HISTSIZE=10000 # Big history #save a lot of history
setopt EXTENDED_HISTORY # Include more information about when the command was executed, etc SAVEHIST=1000
setopt APPEND_HISTORY # Allow multiple terminal sessions to all append to one zsh command history HISTSIZE=1000
setopt HIST_FIND_NO_DUPS # When searching history dont display results already cycled through twice #save more information in history
setopt HIST_EXPIRE_DUPS_FIRST # When duplicates are entered, get rid of the duplicates first when we hit $HISTSIZE setopt EXTENDED_HISTORY
setopt HIST_VERIFY # makes history substitution commands a bit nicer. I dont fully understand #share history among zsh sessions
setopt SHARE_HISTORY # Shares history across multiple zsh sessions, in real time setopt APPEND_HISTORY
setopt HIST_IGNORE_DUPS # Do not write events to history that are duplicates of the immediately previous event setopt SHARE_HISTORY
setopt INC_APPEND_HISTORY # Add commands to history as they are typed, dont wait until shell exit #skip dupes when going through history
setopt HIST_REDUCE_BLANKS # Remove extra blanks from each command line being added to history setopt HIST_FIND_NO_DUPS
#delete dupes first when histsize becomes full
setopt HIST_EXPIRE_DUPS_FIRST
#dont write dupes of the last command to histfile
setopt HIST_IGNORE_DUPS
#write history file as we type
setopt INC_APPEND_HISTORY
#remove extra whitespace from history
setopt HIST_REDUCE_BLANKS
# ZSH Auto Completion #autocomplete
SHORT_HOST=${HOST/.*/}
#the auto complete dump is a cache file where ZSH stores its auto complete data, for faster load times
local ZSH_COMPDUMP="$ZSH_CACHE/acdump-${SHORT_HOST}-${ZSH_VERSION}" #where to store autocomplete data
autoload -Uz compinit autoload -Uz compinit
compinit -i -d "${ZSH_COMPDUMP}" # Init auto completion; tell where to store autocomplete dump compinit
zstyle ':completion:*' menu select # Have the menu highlight as we cycle through options #have the menu highlight while we cycle through options
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' # Case-insensitive (uppercase from lowercase) completion zstyle ':completion:*' menu select
setopt COMPLETE_IN_WORD # Allow completion from within a word/phrase #case insensitive completion
setopt ALWAYS_TO_END # When completing from the middle of a word, move cursor to end of word zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
setopt MENU_COMPLETE # When using auto-complete, put the first option on the line immediately #allow completion from midword
setopt COMPLETE_ALIASES # Turn on completion for aliases as well setopt COMPLETE_IN_WORD
setopt LIST_ROWS_FIRST # Cycle through menus horizontally instead of vertically #move cursor to end of word after completing
setopt ALWAYS_TO_END
#complete aliases as well
setopt COMPLETE_ALIASES
# Globbing #globbing
setopt NO_CASE_GLOB # Case insensitive globbing #case insensitive globbing
setopt EXTENDED_GLOB # Allow the powerful zsh globbing features, see link: setopt NO_CASE_GLOB
# http://www.refining-linux.org/archives/37/ZSH-Gem-2-Extended-globbing-and-expansion/ #sort globs that expand to numbers by number rather than alphabeticly
setopt NUMERIC_GLOB_SORT # Sort globs that expand to numbers numerically, not by letter (i.e. 01 2 03) setopt NUMERIC_GLOB_SORT
# Aliases #aliases
alias vim="nvim" alias vim="nvim"
alias vimdiff="nvim -d" alias vimdiff="nvim -d"
alias mutt="neomutt" alias mutt="neomutt"
alias fuck='sudo $(fc -ln -1)' alias fuck='sudo $(fc -ln -1)'
#alias -g ...='../..' #web searches
#alias -g ....='../../..'
#alias -g .....='../../../..'
#alias -g ......='../../../../..'
#alias -g .......='../../../../../..'
#alias -g ........='../../../../../../..'
alias ls="ls -h --color='auto'"
alias lsa='ls -A'
alias ll='ls -l'
alias la='ls -lA'
alias lx='ls -lXB' #Sort by extension
alias lt='ls -ltr'
alias lk='ls -lSr'
alias cdl=changeDirectory; function changeDirectory { cd $1 ; la }
alias md='mkdir -p'
alias rd='rmdir'
# Copy with a progress bar
alias cpv="rsync -poghb --backup-dir=/tmp/rsync -e /dev/null --progress --"
alias d='dirs -v | head -10' # List the last ten directories we've been to this session, no duplicates
alias ddg='web_search ddg' alias ddg='web_search ddg'
alias github='web_search github' alias github='web_search github'
alias wiki='web_search ddg \!w' alias wiki='web_search ddg \!w'
@ -128,35 +168,17 @@ local LOCAL_ZSHRC=$HOME/.config/zshlocal # Allow the local machine to have
alias map='web_search ddg \!m' alias map='web_search ddg \!m'
alias image='web_search ddg \!i' alias image='web_search ddg \!i'
# Setup grep to be a bit more nice #setup grep to be a bit more nice
# check if 'x' grep argument available
grep-flag-available() {
echo | grep $1 "" >/dev/null 2>&1
}
local GREP_OPTIONS="" local GREP_OPTIONS=""
# color grep results # color grep results
if grep-flag-available --color=auto; then GREP_OPTIONS+=" --color=auto"
GREP_OPTIONS+=" --color=auto"
fi
# ignore VCS folders (if the necessary grep flags are available) # ignore VCS folders (if the necessary grep flags are available)
local VCS_FOLDERS="{.bzr,CVS,.git,.hg,.svn}" local VCS_FOLDERS="{.bzr,CVS,.git,.hg,.svn}"
if grep-flag-available --exclude-dir=.cvs; then GREP_OPTIONS+=" --exclude-dir=$VCS_FOLDERS"
GREP_OPTIONS+=" --exclude-dir=$VCS_FOLDERS" GREP_OPTIONS+=" --exclude=$VCS_FOLDERS"
elif grep-flag-available --exclude=.cvs; then
GREP_OPTIONS+=" --exclude=$VCS_FOLDERS"
fi
# export grep settings # export grep settings
alias grep="grep $GREP_OPTIONS" alias grep="grep $GREP_OPTIONS"
# clean up
unfunction grep-flag-available
# Allow local zsh settings (superseding anything in here) in case I want something specific for certain machines
if [[ -r $LOCAL_ZSHRC ]]; then
source $LOCAL_ZSHRC
fi