ZSH: Beginning of reconfiguring everything
This commit is contained in:
parent
e130455648
commit
154209ffd7
36
.config/zsh/.zlogin
Normal file → Executable file
36
.config/zsh/.zlogin
Normal file → Executable file
@ -1,42 +1,10 @@
|
|||||||
## $ZDOTDIR/.zlogin - Contains commands that should be executed only in login shells
|
## $ZDOTDIR/.zlogin - Contains commands that should be executed only in login shells
|
||||||
|
|
||||||
## Load config files in $ZSH/lib that for stage 3
|
## Load config files in $ZSH/lib that for stage 3
|
||||||
for config_file ($ZDOTDIR/lib/30-*.zsh) source $config_file
|
for config_file (${ZLIBDIR}/30-*.zsh) source $config_file
|
||||||
|
|
||||||
## Run tasks in background
|
|
||||||
(
|
|
||||||
#Initalize and compile completion cache
|
|
||||||
autoload -Uz compinit
|
|
||||||
|
|
||||||
if [ "$(id -u)" -ne 0 ]; then
|
|
||||||
compinit -i # Ignore insecure directories
|
|
||||||
else
|
|
||||||
compinit
|
|
||||||
fi
|
|
||||||
|
|
||||||
## Compile startup files
|
## Compile startup files
|
||||||
|
zwcautocompile
|
||||||
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
|
|
||||||
)
|
|
||||||
|
|
||||||
## Update or install vim plugins
|
|
||||||
#vim -i NONE +PlugUpdate +PlugClean! +qal
|
|
||||||
|
|
||||||
## Print some system info
|
## Print some system info
|
||||||
uname -npsr
|
uname -npsr
|
||||||
|
2
.config/zsh/.zshrc
Normal file → Executable file
2
.config/zsh/.zshrc
Normal file → Executable file
@ -1,4 +1,4 @@
|
|||||||
## $ZDOTDIR/.zshrc - Should be used to set up aliases, functions, keybindings etc.
|
## $ZDOTDIR/.zshrc - Should be used to set up aliases, functions, keybindings etc.
|
||||||
|
|
||||||
# Load config files in $ZSH/lib that for stage 2
|
# Load config files in $ZSH/lib that for stage 2
|
||||||
for config_file ($ZDOTDIR/lib/20-*.zsh) source $config_file
|
for config_file (${ZLIBDIR}/20-*.zsh) source $config_file
|
||||||
|
4
.config/zsh/autoload/dc
Executable file
4
.config/zsh/autoload/dc
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
function dc() {
|
||||||
|
DOCKER_PARAMS="$@"
|
||||||
|
find . -maxdepth 2 -type f -regextype posix-extended -regex '.*(docker-compose|compose)\.ya?ml' -execdir "docker compose ${DOCKER_PARAMS}" \;
|
||||||
|
}
|
36
.config/zsh/autoload/extract
Executable file
36
.config/zsh/autoload/extract
Executable file
@ -0,0 +1,36 @@
|
|||||||
|
function extract() {
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
# display usage if no parameters given
|
||||||
|
echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
|
||||||
|
echo " extract <path/file_name_1.ext> [path/file_name_2.ext] [path/file_name_3.ext]"
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
for n in $@; do
|
||||||
|
if [ -f "$n" ]; then
|
||||||
|
case "${n%,}" in
|
||||||
|
*.tar.bz2 | *.tar.gz | *.tar.xz | *.tbz2 | *.tgz | *.txz | *.tar)
|
||||||
|
tar xvf "$n"
|
||||||
|
;;
|
||||||
|
*.lzma) unlzma ./"$n" ;;
|
||||||
|
*.bz2) bunzip2 ./"$n" ;;
|
||||||
|
*.rar) unrar x -ad ./"$n" ;;
|
||||||
|
*.gz) gunzip ./"$n" ;;
|
||||||
|
*.zip) unzip ./"$n" ;;
|
||||||
|
*.z) uncompress ./"$n" ;;
|
||||||
|
*.7z | *.arj | *.cab | *.chm | *.deb | *.dmg | *.iso | *.lzh | *.msi | *.rpm | *.udf | *.wim | *.xar)
|
||||||
|
7z x ./"$n"
|
||||||
|
;;
|
||||||
|
*.xz) unxz ./"$n" ;;
|
||||||
|
*.exe) cabextract ./"$n" ;;
|
||||||
|
*)
|
||||||
|
echo "extract: '$n' - unknown archive method"
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
echo "'$n' - file does not exist"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
21
.config/zsh/autoload/zwcautocompile
Normal file
21
.config/zsh/autoload/zwcautocompile
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
## Automatically compile all compilable files to zwc
|
||||||
|
|
||||||
|
function zwcautocompile () {
|
||||||
|
autoload -Uz zrecompile
|
||||||
|
|
||||||
|
for zsh_file in $(find ${ZDOTDIR} -type f -maxdepth 3 \( -name "*.zsh" -o -name ".zlogin" -o -name ".zshrc" \) ! -name "*.zwc" ! -name "*.zwc.old"); do
|
||||||
|
zrecompile -pq $zsh_file && rm -f $zsh_file.zwc.old
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -d ${ZAUTOLOADDIR} ]]; then
|
||||||
|
for f in ${ZAUTOLOADDIR}/*; do
|
||||||
|
zrecompile -pq $f && rm -f $f.zwc.old
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -d ${ZLIBDIR} ]]; then
|
||||||
|
for f in ${ZLIBDIR}/*; do
|
||||||
|
zrecompile -pq $f && rm -f $f.zwc.old
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
8
.config/zsh/autoload/zwcpurge
Normal file
8
.config/zsh/autoload/zwcpurge
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
## Purge all compiled zwc files
|
||||||
|
|
||||||
|
function zwcpurge () {
|
||||||
|
autoload -Uz zrecompile
|
||||||
|
for zsh_file in $(find ${ZDOTDIR} -maxdepth 3 -type f \( -name "*.zwc" -o -name "*.zwc.old" \)); do
|
||||||
|
rm -f ${zsh_file}
|
||||||
|
done
|
||||||
|
}
|
2
.config/zsh/lib/10-path.zsh → .config/zsh/conf.d/10-path.zsh
Normal file → Executable file
2
.config/zsh/lib/10-path.zsh → .config/zsh/conf.d/10-path.zsh
Normal file → Executable file
@ -13,7 +13,7 @@ _prepath() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_prepath /usr/bin /bin /usr/sbin /sbin /usr/local/bin /usr/local/sbin # BSD and macOS
|
_prepath /usr/bin /bin /usr/sbin /sbin /usr/local/bin /usr/local/sbin # BSD and macOS
|
||||||
_prepath /opt/homebrew/bin /opt/homebrew/sbin # Homebrew on Apple Silicon
|
_prepath /opt/homebrew/bin /opt/homebrew/sbin /usr/local/bin # Homebrew on macOS
|
||||||
_prepath ~/bin ~/.local/bin # $HOME
|
_prepath ~/bin ~/.local/bin # $HOME
|
||||||
|
|
||||||
unfunction _prepath
|
unfunction _prepath
|
9
.config/zsh/lib/20-aliases.zsh → .config/zsh/conf.d/20-aliases.zsh
Normal file → Executable file
9
.config/zsh/lib/20-aliases.zsh → .config/zsh/conf.d/20-aliases.zsh
Normal file → Executable file
@ -7,10 +7,19 @@ if _exists vim; then
|
|||||||
alias vim="vim -p"
|
alias vim="vim -p"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
## ls/eza
|
||||||
|
if _exists eza; then
|
||||||
|
alias eza="eza --color --icons --git"
|
||||||
|
alias ls="eza"
|
||||||
|
fi
|
||||||
|
|
||||||
unfunction _exists
|
unfunction _exists
|
||||||
|
|
||||||
|
|
||||||
alias mkdir="mkdir -p"
|
alias mkdir="mkdir -p"
|
||||||
|
alias ..="cd .."
|
||||||
alias ...="cd ../.."
|
alias ...="cd ../.."
|
||||||
|
alias ....="cd ../../.."
|
||||||
alias google="ping -c 10240000 google.com"
|
alias google="ping -c 10240000 google.com"
|
||||||
alias history="history -i"
|
alias history="history -i"
|
||||||
alias sulast="sudo $(history -p !-1)"
|
alias sulast="sudo $(history -p !-1)"
|
11
.config/zsh/conf.d/20-autoload.zsh
Executable file
11
.config/zsh/conf.d/20-autoload.zsh
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
# Autoload additional functions
|
||||||
|
|
||||||
|
if [[ -d "${ZAUTOLOADDIR}" ]]; then
|
||||||
|
|
||||||
|
fpath=($fpath ${ZAUTOLOADDIR})
|
||||||
|
|
||||||
|
# Load functions
|
||||||
|
for func in ${ZAUTOLOADDIR}/*; do
|
||||||
|
autoload -Uz ${func:t}
|
||||||
|
done
|
||||||
|
fi
|
11
.config/zsh/lib/20-history.zsh → .config/zsh/conf.d/20-history.zsh
Normal file → Executable file
11
.config/zsh/lib/20-history.zsh → .config/zsh/conf.d/20-history.zsh
Normal file → Executable file
@ -1,5 +1,5 @@
|
|||||||
## Command history configuration
|
## Command history configuration
|
||||||
HISTFILE=$ZDOTDIR/history
|
HISTFILE="${ZCACHE}/history"
|
||||||
HISTSIZE=1000000000
|
HISTSIZE=1000000000
|
||||||
SAVEHIST=1000000000
|
SAVEHIST=1000000000
|
||||||
|
|
||||||
@ -14,10 +14,11 @@ setopt histignorespace
|
|||||||
setopt histnostore
|
setopt histnostore
|
||||||
setopt share_history
|
setopt share_history
|
||||||
export HISTORY_IGNORE="([bf]g *|disown|cd ..|cd -)"
|
export HISTORY_IGNORE="([bf]g *|disown|cd ..|cd -)"
|
||||||
|
HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE=1
|
||||||
|
|
||||||
# Make up and down arrow take what’s typed on the commandline in to account.
|
# # Make up and down arrow take what’s typed on the commandline in to account.
|
||||||
|
|
||||||
autoload -Uz up-line-or-beginning-search down-line-or-beginning-search
|
# autoload -Uz up-line-or-beginning-search down-line-or-beginning-search
|
||||||
|
|
||||||
zle -N up-line-or-beginning-search
|
# zle -N up-line-or-beginning-search
|
||||||
zle -N down-line-or-beginning-search
|
# zle -N down-line-or-beginning-search
|
3
.config/zsh/conf.d/20-key_bindings.zsh
Executable file
3
.config/zsh/conf.d/20-key_bindings.zsh
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
# Search
|
||||||
|
bindkey '^[[A' history-substring-search-up # Up arrow
|
||||||
|
bindkey '^[[B' history-substring-search-down # down arrow
|
0
.config/zsh/lib/30-misc.zsh → .config/zsh/conf.d/30-misc.zsh
Normal file → Executable file
0
.config/zsh/lib/30-misc.zsh → .config/zsh/conf.d/30-misc.zsh
Normal file → Executable file
3
.config/zsh/conf.d/30-plugin-pure.zsh
Normal file
3
.config/zsh/conf.d/30-plugin-pure.zsh
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
PURE_CMD_MAX_EXEC_TIME=10
|
||||||
|
PURE_PROMPT_SYMBOL="❯"
|
||||||
|
PURE_PROMPT_VICMD_SYMBOL="❮"
|
28
.config/zsh/conf.d/30-zsh_unplugged.zsh
Executable file
28
.config/zsh/conf.d/30-zsh_unplugged.zsh
Executable file
@ -0,0 +1,28 @@
|
|||||||
|
# get zsh_unplugged and store it with your other plugins
|
||||||
|
if [[ ! -d ${ZPLUGINDIR}/zsh_unplugged ]]; then
|
||||||
|
git clone --quiet https://github.com/mattmc3/zsh_unplugged ${ZPLUGINDIR}/zsh_unplugged
|
||||||
|
fi
|
||||||
|
source ${ZPLUGINDIR}/zsh_unplugged/zsh_unplugged.zsh
|
||||||
|
|
||||||
|
function plugin-update {
|
||||||
|
for d in ${ZPLUGINDIR}/*/.git(/); do
|
||||||
|
echo "Updating ${d:h:t}..."
|
||||||
|
command git -C "${d:h}" pull --ff --recurse-submodules --depth 1 --rebase --autostash
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# make list of the Zsh plugins you use
|
||||||
|
plugin_repos=(
|
||||||
|
mattmc3/ez-compinit
|
||||||
|
sindresorhus/pure # A pretty, minimal and fast ZSH prompt.
|
||||||
|
zsh-users/zsh-completions # Additional completion definitions for ZSH
|
||||||
|
rupa/z # Tracks your most used directories, based on 'frecency'.
|
||||||
|
Skylor-Tang/auto-venv # Automatically activates the Python virtual environment in the current directory or its parent directories.
|
||||||
|
|
||||||
|
zsh-users/zsh-syntax-highlighting
|
||||||
|
zsh-users/zsh-history-substring-search
|
||||||
|
zsh-users/zsh-autosuggestions
|
||||||
|
)
|
||||||
|
|
||||||
|
# load plugins
|
||||||
|
plugin-load ${plugin_repos}
|
@ -1,35 +0,0 @@
|
|||||||
function extract() {
|
|
||||||
if [ -z "$1" ]; then
|
|
||||||
# display usage if no parameters given
|
|
||||||
echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
|
|
||||||
echo " extract <path/file_name_1.ext> [path/file_name_2.ext] [path/file_name_3.ext]"
|
|
||||||
return 1
|
|
||||||
else
|
|
||||||
for n in $@
|
|
||||||
do
|
|
||||||
if [ -f "$n" ] ; then
|
|
||||||
case "${n%,}" in
|
|
||||||
*.tar.bz2|*.tar.gz|*.tar.xz|*.tbz2|*.tgz|*.txz|*.tar)
|
|
||||||
tar xvf "$n" ;;
|
|
||||||
*.lzma) unlzma ./"$n" ;;
|
|
||||||
*.bz2) bunzip2 ./"$n" ;;
|
|
||||||
*.rar) unrar x -ad ./"$n" ;;
|
|
||||||
*.gz) gunzip ./"$n" ;;
|
|
||||||
*.zip) unzip ./"$n" ;;
|
|
||||||
*.z) uncompress ./"$n" ;;
|
|
||||||
*.7z|*.arj|*.cab|*.chm|*.deb|*.dmg|*.iso|*.lzh|*.msi|*.rpm|*.udf|*.wim|*.xar)
|
|
||||||
7z x ./"$n" ;;
|
|
||||||
*.xz) unxz ./"$n" ;;
|
|
||||||
*.exe) cabextract ./"$n" ;;
|
|
||||||
*)
|
|
||||||
echo "extract: '$n' - unknown archive method"
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
else
|
|
||||||
echo "'$n' - file does not exist"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
function tmix () {
|
|
||||||
set -o shwordsplit
|
|
||||||
|
|
||||||
SESSION="${TMIX_SESSION:-TMIX}"
|
|
||||||
SERVERS="${TMIX_SERVERS}"
|
|
||||||
|
|
||||||
if [[ $1 == "kill" ]]; then
|
|
||||||
echo "Killing tmux session $SESSION"
|
|
||||||
tmux kill-session -t "${SESSION}"
|
|
||||||
else
|
|
||||||
if [ -z "$SERVERS" ]; then
|
|
||||||
# display usage if no parameters given
|
|
||||||
echo "Usage: tmix"
|
|
||||||
echo "No servers configured. define them as TMIX_SERVERS=\"<SERVER> <SERVER> <SERVER>\" e.g. in ${ZDOTDIR}/lib/30-extras.zsh"
|
|
||||||
else
|
|
||||||
echo "Creating tmux session $SESSION"
|
|
||||||
tmux new-session -d -s "${SESSION}"
|
|
||||||
|
|
||||||
create_session=$?
|
|
||||||
if [[ $create_session = 0 ]]; then
|
|
||||||
for SERVER in ${SERVERS}; do
|
|
||||||
echo ">>> Connecting to ${SERVER}"
|
|
||||||
tmux new-window -n ${SERVER} -t ${SESSION}:
|
|
||||||
tmux send-keys -t ${SESSION}:${SERVER} "mosh ${SERVER} -- sudo tmux a -d" C-m
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
|
|
||||||
declare -U fpath
|
|
||||||
|
|
||||||
fpath=($fpath $ZDOTDIR/completions/)
|
|
||||||
fpath=($fpath /usr/local/share/zsh/site-functions)
|
|
||||||
fpath=($fpath /opt/homebrew/share/zsh/site-functions)
|
|
||||||
|
|
||||||
# case insensitive path-completion
|
|
||||||
|
|
||||||
zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*'
|
|
||||||
|
|
||||||
# show descriptions when autocompleting
|
|
||||||
zstyle ':completion:*' auto-description 'specify: %d'
|
|
||||||
zstyle ':completion:*' format 'Completing %d'
|
|
||||||
|
|
||||||
# partial completion suggestions
|
|
||||||
zstyle ':completion:*' list-suffixes true
|
|
||||||
zstyle ':completion:*' expand prefix suffix
|
|
||||||
|
|
||||||
# list with colors
|
|
||||||
zstyle ':completion:*' list-colors ''x
|
|
||||||
|
|
||||||
# disable named-directories autocompletion
|
|
||||||
zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories
|
|
||||||
cdpath=(.)
|
|
||||||
|
|
||||||
if [ "x$COMPLETION_WAITING_DOTS" = "xtrue" ]; then
|
|
||||||
expand-or-complete-with-dots() {
|
|
||||||
echo -n "\e[31m......\e[0m"
|
|
||||||
zle expand-or-complete
|
|
||||||
zle redisplay
|
|
||||||
}
|
|
||||||
zle -N expand-or-complete-with-dots
|
|
||||||
bindkey "^I" expand-or-complete-with-dots
|
|
||||||
fi
|
|
||||||
|
|
||||||
# load completion
|
|
||||||
autoload -Uz compinit && compinit
|
|
@ -1,11 +0,0 @@
|
|||||||
setopt correct_all
|
|
||||||
|
|
||||||
alias cap='nocorrect cap'
|
|
||||||
alias man='nocorrect man'
|
|
||||||
alias tree='nocorrect tree'
|
|
||||||
alias mv='nocorrect mv'
|
|
||||||
alias mkdir='nocorrect mkdir'
|
|
||||||
alias vim='nocorrect vim'
|
|
||||||
alias zsh='nocorrect zsh'
|
|
||||||
alias ssh='nocorrect ssh'
|
|
||||||
alias tmix='nocorrect tmix'
|
|
@ -1,4 +0,0 @@
|
|||||||
# Changing/making/removing directory
|
|
||||||
setopt auto_name_dirs
|
|
||||||
setopt auto_pushd
|
|
||||||
setopt pushd_ignore_dups
|
|
@ -1,4 +0,0 @@
|
|||||||
fpath=($fpath $ZDOTDIR/functions)
|
|
||||||
|
|
||||||
autoload extract
|
|
||||||
autoload tmix
|
|
@ -1,34 +0,0 @@
|
|||||||
# TODO: Explain what some of this does..
|
|
||||||
|
|
||||||
bindkey -e
|
|
||||||
bindkey '\ew' kill-region
|
|
||||||
bindkey -s '\el' "ls\n"
|
|
||||||
bindkey -s '\e.' "..\n"
|
|
||||||
bindkey '^r' history-incremental-search-backward
|
|
||||||
bindkey "^[[5~" up-line-or-history
|
|
||||||
bindkey "^[[6~" down-line-or-history
|
|
||||||
|
|
||||||
# make search up and down work, so partially type and hit up/down to find relevant stuff
|
|
||||||
bindkey '^[[A' up-line-or-beginning-search # Arrow up
|
|
||||||
bindkey '^[OA' up-line-or-beginning-search
|
|
||||||
bindkey '^[[B' down-line-or-beginning-search # Arrow down
|
|
||||||
bindkey '^[OB' down-line-or-beginning-search
|
|
||||||
|
|
||||||
bindkey "^[[H" beginning-of-line
|
|
||||||
bindkey "^[[1~" beginning-of-line
|
|
||||||
bindkey "^[OH" beginning-of-line
|
|
||||||
bindkey "^[[F" end-of-line
|
|
||||||
bindkey "^[[4~" end-of-line
|
|
||||||
bindkey "^[OF" end-of-line
|
|
||||||
bindkey ' ' magic-space # also do history expansion on space
|
|
||||||
|
|
||||||
bindkey "^[[1;5C" forward-word
|
|
||||||
bindkey "^[[1;5D" backward-word
|
|
||||||
|
|
||||||
bindkey '^[[Z' reverse-menu-complete
|
|
||||||
|
|
||||||
# Make the delete key (or Fn + Delete on the Mac) work instead of outputting a ~
|
|
||||||
bindkey '^?' backward-delete-char
|
|
||||||
bindkey "^[[3~" delete-char
|
|
||||||
bindkey "^[3;5~" delete-char
|
|
||||||
bindkey "\e[3~" delete-char
|
|
@ -1,25 +0,0 @@
|
|||||||
# Directory shortcuts
|
|
||||||
# You can use cd ~x and vim ~x/file instead of cd /very/long/and/often/accessed/path. Some examples:
|
|
||||||
hash -d bin=$HOME/bin
|
|
||||||
|
|
||||||
case `uname` in
|
|
||||||
Darwin)
|
|
||||||
hash -d hucb=$HOME/Sites/christianbaer.me
|
|
||||||
;;
|
|
||||||
Linux)
|
|
||||||
# commands for Linux go here
|
|
||||||
;;
|
|
||||||
FreeBSD)
|
|
||||||
hash -d etc=/usr/local/etc
|
|
||||||
hash -d www=/usr/local/www/ngineerx
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
insert_doas() { zle beginning-of-line; zle -U "doas " }
|
|
||||||
replace_rm() { zle beginning-of-line; zle delete-word; zle -U "rm " }
|
|
||||||
|
|
||||||
zle -N insert-doas insert_doas
|
|
||||||
zle -N replace-rm replace_rm
|
|
||||||
|
|
||||||
bindkey '^s' insert-doas
|
|
||||||
bindkey '^r' replace-rm
|
|
@ -1,26 +0,0 @@
|
|||||||
# ls colors
|
|
||||||
autoload colors; colors;
|
|
||||||
export LSCOLORS="Gxfxcxdxbxegedabagacad"
|
|
||||||
#export LS_COLORS
|
|
||||||
|
|
||||||
# Enable ls colors
|
|
||||||
if [ "$DISABLE_LS_COLORS" != "true" ]
|
|
||||||
then
|
|
||||||
# Find the option for using colors in ls, depending on the version: Linux or BSD
|
|
||||||
ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G'
|
|
||||||
fi
|
|
||||||
|
|
||||||
#setopt no_beep
|
|
||||||
setopt auto_cd
|
|
||||||
setopt multios
|
|
||||||
setopt cdablevarS
|
|
||||||
|
|
||||||
if [[ x$WINDOW != x ]]
|
|
||||||
then
|
|
||||||
SCREEN_NO="%B$WINDOW%b "
|
|
||||||
else
|
|
||||||
SCREEN_NO=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Apply theming defaults
|
|
||||||
PS1="%n@%m:%~%# "
|
|
@ -1,24 +0,0 @@
|
|||||||
typeset -Ag FX FG BG
|
|
||||||
|
|
||||||
## Set Colors on BSD system
|
|
||||||
LSCOLORS="gxfxcxdxbxegedabagacad"
|
|
||||||
CLICOLOR="YES"
|
|
||||||
|
|
||||||
## Load .dir_colors for GNU systems
|
|
||||||
if command -v dircolors &> /dev/null; then
|
|
||||||
test -r "$XDG_CONFIG_HOME/dircolors" && eval $(dircolors "$XDG_CONFIG_HOME"/dircolors)
|
|
||||||
fi
|
|
||||||
|
|
||||||
FX=(
|
|
||||||
reset "%{[00m%}"
|
|
||||||
bold "%{[01m%}" no-bold "%{[22m%}"
|
|
||||||
italic "%{[03m%}" no-italic "%{[23m%}"
|
|
||||||
underline "%{[04m%}" no-underline "%{[24m%}"
|
|
||||||
blink "%{[05m%}" no-blink "%{[25m%}"
|
|
||||||
reverse "%{[07m%}" no-reverse "%{[27m%}"
|
|
||||||
)
|
|
||||||
|
|
||||||
for color in {000..255}; do
|
|
||||||
FG[$color]="%{[38;5;${color}m%}"
|
|
||||||
BG[$color]="%{[48;5;${color}m%}"
|
|
||||||
done
|
|
Binary file not shown.
@ -1,3 +0,0 @@
|
|||||||
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
|
|
||||||
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
|
|
||||||
fi
|
|
@ -1,54 +0,0 @@
|
|||||||
setopt prompt_subst
|
|
||||||
autoload -U promptinit
|
|
||||||
promptinit
|
|
||||||
|
|
||||||
## Print bold red username when UID = 0, else unsername in green
|
|
||||||
p_user='%(!.%F{red}%B%n%b%f.%F{green}%n%f)'
|
|
||||||
## Print red # when UID = 0, else @ in blue
|
|
||||||
p_at='%(!.%F{red}%B#%b%f.%F{blue}@%f)'
|
|
||||||
## Print hostname in blue
|
|
||||||
p_host='%F{blue}%m%f'
|
|
||||||
## Print path in yellow
|
|
||||||
p_path='%F{yellow}%~%f'
|
|
||||||
## Print prompt sign in red if the previous command retunend and error, otherwise print it in white
|
|
||||||
p_pr='%(?.%F{magenta}.%F{red})%B〉%b%f%'
|
|
||||||
|
|
||||||
# Add green arrows (⇣⇡) if connection is via ssh
|
|
||||||
if [[ "${SSH_CONNECTION}" ]]; then
|
|
||||||
p_ssh=" %F{green}⇣⇡%f";
|
|
||||||
fi;
|
|
||||||
|
|
||||||
# Transient prompt based on https://github.com/romkatv/powerlevel10k/issues/888#issuecomment-657969840
|
|
||||||
zle-line-init() {
|
|
||||||
emulate -L zsh
|
|
||||||
|
|
||||||
[[ $CONTEXT == start ]] || return 0
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
zle .recursive-edit
|
|
||||||
local -i ret=$?
|
|
||||||
[[ $ret == 0 && $KEYS == $'\4' ]] || break
|
|
||||||
[[ -o ignore_eof ]] || exit 0
|
|
||||||
done
|
|
||||||
|
|
||||||
local saved_prompt=$PROMPT
|
|
||||||
local saved_rprompt=$RPROMPT
|
|
||||||
PROMPT='${nl}$p_pr '
|
|
||||||
RPROMPT=''
|
|
||||||
zle .reset-prompt
|
|
||||||
PROMPT=$saved_prompt
|
|
||||||
RPROMPT=$saved_rprompt
|
|
||||||
|
|
||||||
if (( ret )); then
|
|
||||||
zle .send-break
|
|
||||||
else
|
|
||||||
zle .accept-line
|
|
||||||
fi
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
|
|
||||||
zle -N zle-line-init
|
|
||||||
|
|
||||||
nl=$'\n'
|
|
||||||
PS1="${nl}$p_user$p_at$p_host$p_ssh $p_path${nl}$p_pr"
|
|
||||||
#unset p_at p_user p_host p_path p_pr
|
|
@ -1,70 +0,0 @@
|
|||||||
# Source: Josh Dick https://gist.github.com/joshdick/4415470
|
|
||||||
|
|
||||||
# Adapted from code found at <https://gist.github.com/1712320>.
|
|
||||||
|
|
||||||
setopt prompt_subst
|
|
||||||
autoload -U colors && colors # Enable colors in prompt
|
|
||||||
|
|
||||||
# Modify the colors and symbols in these variables as desired.
|
|
||||||
GIT_PROMPT_SYMBOL="%{$fg[blue]%}±"
|
|
||||||
GIT_PROMPT_PREFIX="%{$fg[green]%}(%{$reset_color%}"
|
|
||||||
GIT_PROMPT_SUFFIX="%{$fg[green]%})%{$reset_color%}"
|
|
||||||
GIT_PROMPT_AHEAD="%{$fg[red]%}ANUM%{$reset_color%}"
|
|
||||||
GIT_PROMPT_BEHIND="%{$fg[cyan]%}BNUM%{$reset_color%}"
|
|
||||||
GIT_PROMPT_MERGING="%{$fg[magenta]%}⚡︎%{$reset_color%}"
|
|
||||||
GIT_PROMPT_UNTRACKED="%{$fg[red]%}●%{$reset_color%}"
|
|
||||||
GIT_PROMPT_MODIFIED="%{$fg[yellow]%}●%{$reset_color%}"
|
|
||||||
GIT_PROMPT_STAGED="%{$fg[green]%}●%{$reset_color%}"
|
|
||||||
|
|
||||||
# Show Git branch/tag, or name-rev if on detached head
|
|
||||||
parse_git_branch() {
|
|
||||||
(git symbolic-ref -q HEAD || git name-rev --name-only --no-undefined --always HEAD) 2> /dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
# Show different symbols as appropriate for various Git repository states
|
|
||||||
parse_git_state() {
|
|
||||||
|
|
||||||
# Compose this value via multiple conditional appends.
|
|
||||||
local GIT_STATE=""
|
|
||||||
|
|
||||||
local NUM_AHEAD="$(git log --oneline @{u}.. 2> /dev/null | wc -l | tr -d ' ')"
|
|
||||||
if [ "$NUM_AHEAD" -gt 0 ]; then
|
|
||||||
GIT_STATE=$GIT_STATE${GIT_PROMPT_AHEAD//NUM/$NUM_AHEAD}
|
|
||||||
fi
|
|
||||||
|
|
||||||
local NUM_BEHIND="$(git log --oneline ..@{u} 2> /dev/null | wc -l | tr -d ' ')"
|
|
||||||
if [ "$NUM_BEHIND" -gt 0 ]; then
|
|
||||||
GIT_STATE=$GIT_STATE${GIT_PROMPT_BEHIND//NUM/$NUM_BEHIND}
|
|
||||||
fi
|
|
||||||
|
|
||||||
local GIT_DIR="$(git rev-parse --git-dir 2> /dev/null)"
|
|
||||||
if [ -n $GIT_DIR ] && test -r $GIT_DIR/MERGE_HEAD; then
|
|
||||||
GIT_STATE=$GIT_STATE$GIT_PROMPT_MERGING
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then
|
|
||||||
GIT_STATE=$GIT_STATE$GIT_PROMPT_UNTRACKED
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! git diff --quiet 2> /dev/null; then
|
|
||||||
GIT_STATE=$GIT_STATE$GIT_PROMPT_MODIFIED
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! git diff --cached --quiet 2> /dev/null; then
|
|
||||||
GIT_STATE=$GIT_STATE$GIT_PROMPT_STAGED
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -n $GIT_STATE ]]; then
|
|
||||||
echo "$GIT_PROMPT_PREFIX$GIT_STATE$GIT_PROMPT_SUFFIX"
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
# If inside a Git repository, print its branch and state
|
|
||||||
git_prompt_string() {
|
|
||||||
local git_where="$(parse_git_branch)"
|
|
||||||
[ -n "$git_where" ] && echo "$GIT_PROMPT_SYMBOL$(parse_git_state)$GIT_PROMPT_PREFIX%{$fg[yellow]%}${git_where#(refs/heads/|tags/)}$GIT_PROMPT_SUFFIX"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Set the right-hand prompt
|
|
||||||
RPS1='$(git_prompt_string)'
|
|
7
.zshenv
7
.zshenv
@ -8,5 +8,10 @@ export XDG_DATA_HOME=${XDG_DATA_HOME:=${HOME}/.local/share}
|
|||||||
# Where to look for zsh config
|
# Where to look for zsh config
|
||||||
export ZDOTDIR=${ZDOTDIR:=${XDG_CONFIG_HOME}/zsh}
|
export ZDOTDIR=${ZDOTDIR:=${XDG_CONFIG_HOME}/zsh}
|
||||||
|
|
||||||
|
export ZAUTOLOADDIR="${ZDOTDIR}/autoload" # Autoladed functions
|
||||||
|
export ZPLUGINDIR="${ZDOTDIR}/plugins" # External plugins
|
||||||
|
export ZLIBDIR="${ZDOTDIR}/conf.d" # Configuration files
|
||||||
|
export ZCACHE="${XDG_CACHE_HOME}/zsh" # Cache directory for history and zcompdump
|
||||||
|
|
||||||
# Load config files in $ZSH/lib that for stage 1
|
# Load config files in $ZSH/lib that for stage 1
|
||||||
for config_file ($ZDOTDIR/lib/10-*.zsh) source $config_file
|
for config_file (${ZLIBDIR}/10-*.zsh) source $config_file
|
||||||
|
8
Makefile
8
Makefile
@ -108,12 +108,12 @@ deploy-youtubedl: ## Deploy youtube-dl config
|
|||||||
deploy-zsh: ## Deploy zsh config
|
deploy-zsh: ## Deploy zsh config
|
||||||
@echo "\033[1;32m>>>\033[1;0m Deploy zsh config to ${HOMEDIR}/.config/zsh"
|
@echo "\033[1;32m>>>\033[1;0m Deploy zsh config to ${HOMEDIR}/.config/zsh"
|
||||||
@mkdir -p ${HOMEDIR}/.config/zsh
|
@mkdir -p ${HOMEDIR}/.config/zsh
|
||||||
@mkdir -p ${HOMEDIR}/.config/zsh/functions
|
@mkdir -p ${HOMEDIR}/.config/zsh/autoload
|
||||||
@mkdir -p ${HOMEDIR}/.config/zsh/lib
|
@mkdir -p ${HOMEDIR}/.config/zsh/conf.d
|
||||||
@cp .zshenv ${HOMEDIR}/
|
@cp .zshenv ${HOMEDIR}/
|
||||||
@cp .config/zsh/.z* ${HOMEDIR}/.config/zsh
|
@cp .config/zsh/.z* ${HOMEDIR}/.config/zsh
|
||||||
@cp .config/zsh/functions/* ${HOMEDIR}/.config/zsh/functions
|
@cp .config/zsh/functions/* ${HOMEDIR}/.config/zsh/autoload
|
||||||
@cp .config/zsh/lib/*.zsh ${HOMEDIR}/.config/zsh/lib
|
@cp .config/zsh/lib/*.zsh ${HOMEDIR}/.config/zsh/conf.d
|
||||||
|
|
||||||
deploy-brewfile: ## Deploy Brewfile
|
deploy-brewfile: ## Deploy Brewfile
|
||||||
@echo "\033[1;32m>>>\033[1;0m Deploy Brewfile to ${HOMEDIR}/.config/"
|
@echo "\033[1;32m>>>\033[1;0m Deploy Brewfile to ${HOMEDIR}/.config/"
|
||||||
|
10
README.md
10
README.md
@ -59,15 +59,7 @@ The config delivers some nice extra functions.
|
|||||||
|
|
||||||
_extract_ can be run with _extract <filename>_ to extract archives in any given formats.
|
_extract_ can be run with _extract <filename>_ to extract archives in any given formats.
|
||||||
|
|
||||||
### tmix()
|
It utilizes [zsh_unplugged(]https://github.com/mattmc3/zsh_unplugged) for downloading plugins and the small amount of plugins is carefully picked.
|
||||||
|
|
||||||
_tmix_ creates a new tmux session and connects to a given list of servers with mosh and attaches to a tmux session at the server.
|
|
||||||
|
|
||||||
You must define a space separated list of servers as _$TMIX_SERVERS=“<SERVERS>”_ e.g. in _~/.zsh/lib/30-extras.zsh_.
|
|
||||||
|
|
||||||
You can define a name for the used session in _$TMIX_SESSION=“<SESSION>”_. Otherwise it will use „TMIX“.
|
|
||||||
|
|
||||||
_tmix kill_ kills the session.
|
|
||||||
|
|
||||||
## tmux config
|
## tmux config
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user