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-* *.sublime-*
*.log *.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/local/bin /bin /usr/local/sbin # General
_prepath /usr/bin /usr/sbin /sbin /Library/Apple/usr/bin # macOS _prepath /usr/bin /usr/sbin /sbin /Library/Apple/usr/bin # macOS
_prepath /usr/sbin /sbin # FreeBSD _prepath /usr/sbin /sbin # FreeBSD
_prepath ~/bin
_prepath "$HOME/bin"
unfunction _prepath unfunction _prepath

View File

@ -10,13 +10,12 @@ fi
unfunction _exists unfunction _exists
alias ls='ls --color=always -h' alias ls='ls --color=always -h'
alias ll='ls -la' alias ll='ls -la'
alias ...='cd ../..' alias ...='cd ../..'
alias foldersize='du -sh' 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 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 case `uname` in
Darwin) Darwin)
@ -27,7 +26,6 @@ case `uname` in
alias r='open -a' alias r='open -a'
alias sulast='sudo $(history -p !-1)' alias sulast='sudo $(history -p !-1)'
alias ydl="youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best'" 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' alias nmap_localnet='nmap -sP 10.0.3.0/24'
;; ;;
Linux) Linux)
@ -35,5 +33,6 @@ case `uname` in
;; ;;
FreeBSD) FreeBSD)
# commands for FreeBSD go here # commands for FreeBSD go here
alias stl="sockstat -l"
;; ;;
esac esac

View File

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

View File

@ -1,4 +1,4 @@
# Changing/making/removing directory # Changing/making/removing directory
setopt auto_name_dirs setopt auto_name_dirs
setopt auto_pushd setopt auto_pushd
setopt pushd_ignore_dups setopt pushd_ignore_dups

View File

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

View File

@ -23,4 +23,4 @@ else
fi fi
# Apply theming defaults # Apply theming defaults
PS1="%n@%m:%~%# " PS1="%n@%m:%~%# "

View File

@ -16,10 +16,3 @@ for color in {000..255}; do
FG[$color]="%{[38;5;${color}m%}" FG[$color]="%{[38;5;${color}m%}"
BG[$color]="%{[48;5;${color}m%}" BG[$color]="%{[48;5;${color}m%}"
done 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 ' PROMPT+='%F{yellow}%~%f '
# Change green arrows (⇣⇡) if connection is via ssh # Change green arrows (⇣⇡) if connection is via ssh
if [[ "${SSH_CLIENT}" ]]; then if [[ "${SSH_CONNECTION}" ]]; then
PROMPT+="%F{green}⇣⇡%f %F{white}〉%f"; PROMPT+="%F{green}⇣⇡%f %F{white}〉%f";
else else
PROMPT+="%F{white}〉%f"; 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