Restructured zsh config

This commit is contained in:
Christian Baer 2020-06-02 15:59:14 +02:00
parent 8b72233e29
commit 0cd62c36d7
20 changed files with 56 additions and 28 deletions

1
.gitignore vendored
View File

@ -17,3 +17,4 @@ Thumbs.db
*.sublime-*
*.log
.zsh/lib/30-extra.zsh

View File

@ -1,2 +0,0 @@
uname -npsr
uptime

35
.zsh/.zlogin Normal file
View File

@ -0,0 +1,35 @@
## $ZDOTDIR/.zlogin - Contains commands that should be executed only in login shells
# Load config files in $ZSH/lib that for stage 3
for config_file ($ZDOTDIR/lib/30-*.zsh) source $config_file
## Run tasks in background
(
#Initalize and compile completion cache
autoload -Uz compinit
compinit
#Compile startup files
autoload -Uz zrecompile
for ((i=1; i <= $#fpath; ++i)); do
dir=$fpath[i]
zwc=${dir:t}.zwc
if [[ $dir == (.|..) || $dir == (.|..)/* ]]; then
continue
fi
files=($dir/*(N-.))
if [[ -w $dir:h && -n $files ]]; then
files=(${${(M)files%/*/*}#/})
if ( cd $dir:h &&
zrecompile -p -U -z $zwc $files ); then
fpath[i]=$fpath[i].zwc
fi
fi
done
)
## Print some system info
uname -npsr
uptime

4
.zsh/.zshrc Normal file
View File

@ -0,0 +1,4 @@
## $ZDOTDIR/.zshrc - Should be used to set up aliases, functions, keybindings etc.
# Load config files in $ZSH/lib that for stage 2
for config_file ($ZDOTDIR/lib/20-*.zsh) source $config_file

View File

@ -14,7 +14,6 @@ _prepath() {
_prepath /usr/local/bin /bin /usr/local/sbin # General
_prepath /usr/bin /usr/sbin /sbin /Library/Apple/usr/bin # macOS
_prepath /usr/sbin /sbin # FreeBSD
_prepath "$HOME/bin"
_prepath ~/bin
unfunction _prepath

View File

@ -10,13 +10,12 @@ fi
unfunction _exists
alias ls='ls --color=always -h'
alias ll='ls -la'
alias ...='cd ../..'
alias foldersize='du -sh'
alias duf='du -sk * | sort -n | while read size fname; do for unit in k M G T P E Z Y; do if [ $size -lt 1024 ]; then echo -e "${size}${unit}\t${fname}"; break; fi; size=$((size/1024)); done; done'
alias whois="whois -h whois-servers.net"
alias google='ping -c 10240000 google.com'
case `uname` in
Darwin)
@ -27,7 +26,6 @@ case `uname` in
alias r='open -a'
alias sulast='sudo $(history -p !-1)'
alias ydl="youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best'"
alias google='ping -c 10240000 google.com'
alias nmap_localnet='nmap -sP 10.0.3.0/24'
;;
Linux)
@ -35,5 +33,6 @@ case `uname` in
;;
FreeBSD)
# commands for FreeBSD go here
alias stl="sockstat -l"
;;
esac

View File

@ -9,8 +9,8 @@ setopt always_to_end
WORDCHARS=''
zmodload -i zsh/complist
fpath=(~/.zsh/comp/ $fpath)
fpath=(/usr/local/share/zsh/site-functions/ $fpath)
fpath=($fpath $ZDOTDIR/completions/)
fpath=($fpath /usr/local/share/zsh/site-functions/)
## case-insensitive (all),partial-word and then substring completion
if [ "x$CASE_SENSITIVE" = "xtrue" ]; then

View File

@ -1,4 +1,4 @@
fpath+=$ZDOTDIR/functions
fpath=($fpath $ZDOTDIR/functions)
autoload extract
autoload img2iso

View File

@ -16,10 +16,3 @@ for color in {000..255}; do
FG[$color]="%{[38;5;${color}m%}"
BG[$color]="%{[48;5;${color}m%}"
done
# Show all 256 colors with color number
function spectrum_ls() {
for code in {000..255}; do
print -P -- "$code: %F{$code}Test%f"
done
}

View File

@ -12,7 +12,7 @@ fi
PROMPT+='%F{yellow}%~%f '
# Change green arrows (⇣⇡) if connection is via ssh
if [[ "${SSH_CLIENT}" ]]; then
if [[ "${SSH_CONNECTION}" ]]; then
PROMPT+="%F{green}⇣⇡%f %F{white}〉%f";
else
PROMPT+="%F{white}〉%f";

7
.zshenv Normal file
View File

@ -0,0 +1,7 @@
## ~/.zshenv - Should contain commands to set the $PATH and other important environment variables
# Where to look for zsh config
ZDOTDIR=~/.zsh
# Load config files in $ZSH/lib that for stage 3
for config_file ($ZDOTDIR/lib/10-*.zsh) source $config_file

8
.zshrc
View File

@ -1,8 +0,0 @@
ZDOTDIR=~/.zsh
# Load all of the config files in $ZSH/lib that end in .zsh
for config_file ($ZDOTDIR/lib/*.zsh) source $config_file
# Load and run compinit
autoload -U compinit
compinit -i