mirror of
https://github.com/materusPL/nixos-config
synced 2026-06-24 17:36:41 +00:00
materusPC: Init new config
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
# Stolen from ArchWiki
|
||||
|
||||
# create a zkbd compatible hash;
|
||||
# to add other keys to this hash, see: man 5 terminfo
|
||||
typeset -A key
|
||||
|
||||
key[Home]=${terminfo[khome]}
|
||||
|
||||
key[End]=${terminfo[kend]}
|
||||
key[Insert]=${terminfo[kich1]}
|
||||
key[Delete]=${terminfo[kdch1]}
|
||||
key[Up]=${terminfo[kcuu1]}
|
||||
key[Down]=${terminfo[kcud1]}
|
||||
key[Left]=${terminfo[kcub1]}
|
||||
key[Right]=${terminfo[kcuf1]}
|
||||
key[PageUp]=${terminfo[kpp]}
|
||||
key[PageDown]=${terminfo[knp]}
|
||||
|
||||
# setup key accordingly
|
||||
[[ -n "${key[Home]}" ]] && bindkey "${key[Home]}" beginning-of-line
|
||||
[[ -n "${key[End]}" ]] && bindkey "${key[End]}" end-of-line
|
||||
[[ -n "${key[Insert]}" ]] && bindkey "${key[Insert]}" overwrite-mode
|
||||
[[ -n "${key[Delete]}" ]] && bindkey "${key[Delete]}" delete-char
|
||||
[[ -n "${key[Up]}" ]] && bindkey "${key[Up]}" up-line-or-history
|
||||
[[ -n "${key[Down]}" ]] && bindkey "${key[Down]}" down-line-or-history
|
||||
[[ -n "${key[Left]}" ]] && bindkey "${key[Left]}" backward-char
|
||||
[[ -n "${key[Right]}" ]] && bindkey "${key[Right]}" forward-char
|
||||
[[ -n "${key[PageUp]}" ]] && bindkey "${key[PageUp]}" beginning-of-buffer-or-history
|
||||
[[ -n "${key[PageDown]}" ]] && bindkey "${key[PageDown]}" end-of-buffer-or-history
|
||||
|
||||
# Finally, make sure the terminal is in application mode, when zle is
|
||||
# active. Only then are the values from $terminfo valid.
|
||||
if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
|
||||
function zle-line-init () {
|
||||
printf '%s' "${terminfo[smkx]}"
|
||||
}
|
||||
function zle-line-finish () {
|
||||
printf '%s' "${terminfo[rmkx]}"
|
||||
}
|
||||
zle -N zle-line-init
|
||||
zle -N zle-line-finish
|
||||
fi
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,190 @@
|
||||
#Stolen from grml zsh config
|
||||
|
||||
|
||||
function __zsh_compl () {
|
||||
# TODO: This could use some additional information
|
||||
|
||||
# Make sure the completion system is initialised
|
||||
(( ${+_comps} )) || return 1
|
||||
|
||||
# allow one error for every three characters typed in approximate completer
|
||||
zstyle ':completion:*:approximate:' max-errors 'reply=( $((($#PREFIX+$#SUFFIX)/3 )) numeric )'
|
||||
|
||||
# don't complete backup files as executables
|
||||
zstyle ':completion:*:complete:-command-::commands' ignored-patterns '(aptitude-*|*\~)'
|
||||
|
||||
# start menu completion only if it could find no unambiguous initial string
|
||||
zstyle ':completion:*:correct:*' insert-unambiguous true
|
||||
zstyle ':completion:*:corrections' format $'%{\e[0;31m%}%d (errors: %e)%{\e[0m%}'
|
||||
zstyle ':completion:*:correct:*' original true
|
||||
|
||||
# activate color-completion
|
||||
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
|
||||
|
||||
# format on completion
|
||||
zstyle ':completion:*:descriptions' format $'%{\e[0;31m%}completing %B%d%b%{\e[0m%}'
|
||||
|
||||
# automatically complete 'cd -<tab>' and 'cd -<ctrl-d>' with menu
|
||||
# zstyle ':completion:*:*:cd:*:directory-stack' menu yes select
|
||||
|
||||
# insert all expansions for expand completer
|
||||
zstyle ':completion:*:expand:*' tag-order all-expansions
|
||||
zstyle ':completion:*:history-words' list false
|
||||
|
||||
# activate menu
|
||||
zstyle ':completion:*:history-words' menu yes
|
||||
|
||||
# ignore duplicate entries
|
||||
zstyle ':completion:*:history-words' remove-all-dups yes
|
||||
zstyle ':completion:*:history-words' stop yes
|
||||
|
||||
# match uppercase from lowercase
|
||||
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
|
||||
|
||||
# separate matches into groups
|
||||
zstyle ':completion:*:matches' group 'yes'
|
||||
zstyle ':completion:*' group-name ''
|
||||
|
||||
if [[ "$NOMENU" -eq 0 ]] ; then
|
||||
# if there are more than 5 options allow selecting from a menu
|
||||
zstyle ':completion:*' menu select=5
|
||||
else
|
||||
# don't use any menus at all
|
||||
setopt no_auto_menu
|
||||
fi
|
||||
|
||||
zstyle ':completion:*:messages' format '%d'
|
||||
zstyle ':completion:*:options' auto-description '%d'
|
||||
|
||||
# describe options in full
|
||||
zstyle ':completion:*:options' description 'yes'
|
||||
|
||||
# on processes completion complete all user processes
|
||||
zstyle ':completion:*:processes' command 'ps -au$USER'
|
||||
|
||||
# offer indexes before parameters in subscripts
|
||||
zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters
|
||||
|
||||
# provide verbose completion information
|
||||
zstyle ':completion:*' verbose true
|
||||
|
||||
# recent (as of Dec 2007) zsh versions are able to provide descriptions
|
||||
# for commands (read: 1st word in the line) that it will list for the user
|
||||
# to choose from. The following disables that, because it's not exactly fast.
|
||||
zstyle ':completion:*:-command-:*:' verbose false
|
||||
|
||||
# set format for warnings
|
||||
zstyle ':completion:*:warnings' format $'%{\e[0;31m%}No matches for:%{\e[0m%} %d'
|
||||
|
||||
# define files to ignore for zcompile
|
||||
zstyle ':completion:*:*:zcompile:*' ignored-patterns '(*~|*.zwc)'
|
||||
zstyle ':completion:correct:' prompt 'correct to: %e'
|
||||
|
||||
# Ignore completion functions for commands you don't have:
|
||||
zstyle ':completion::(^approximate*):*:functions' ignored-patterns '_*'
|
||||
|
||||
# Provide more processes in completion of programs like killall:
|
||||
zstyle ':completion:*:processes-names' command 'ps c -u ${USER} -o command | uniq'
|
||||
|
||||
# complete manual by their section
|
||||
zstyle ':completion:*:manuals' separate-sections true
|
||||
zstyle ':completion:*:manuals.*' insert-sections true
|
||||
zstyle ':completion:*:man:*' menu yes select
|
||||
|
||||
# Search path for sudo completion
|
||||
zstyle ':completion:*:sudo:*' command-path /usr/local/sbin \
|
||||
/usr/local/bin \
|
||||
/usr/sbin \
|
||||
/usr/bin \
|
||||
/sbin \
|
||||
/bin \
|
||||
/usr/X11R6/bin \
|
||||
/run/current-system/sw/bin \
|
||||
/run/current-system/sw/sbin
|
||||
|
||||
|
||||
|
||||
# provide .. as a completion
|
||||
zstyle ':completion:*' special-dirs ..
|
||||
|
||||
# run rehash on completion so new installed program are found automatically:
|
||||
function _force_rehash () {
|
||||
(( CURRENT == 1 )) && rehash
|
||||
return 1
|
||||
}
|
||||
|
||||
## correction
|
||||
# some people don't like the automatic correction - so run 'NOCOR=1 zsh' to deactivate it
|
||||
if [[ "$NOCOR" -gt 0 ]] ; then
|
||||
zstyle ':completion:*' completer _oldlist _expand _force_rehash _complete _files _ignored
|
||||
setopt nocorrect
|
||||
else
|
||||
# try to be smart about when to use what completer...
|
||||
setopt correct
|
||||
zstyle -e ':completion:*' completer '
|
||||
if [[ $_last_try != "$HISTNO$BUFFER$CURSOR" ]] ; then
|
||||
_last_try="$HISTNO$BUFFER$CURSOR"
|
||||
reply=(_complete _match _ignored _prefix _files)
|
||||
else
|
||||
if [[ $words[1] == (rm|mv) ]] ; then
|
||||
reply=(_complete _files)
|
||||
else
|
||||
reply=(_oldlist _expand _force_rehash _complete _ignored _correct _approximate _files)
|
||||
fi
|
||||
fi'
|
||||
fi
|
||||
|
||||
# command for process lists, the local web server details and host completion
|
||||
zstyle ':completion:*:urls' local 'www' '/var/www/' 'public_html'
|
||||
|
||||
# Some functions, like _apt and _dpkg, are very slow. We can use a cache in
|
||||
# order to speed things up
|
||||
if [[ ${__COMP_CACHING:-yes} == yes ]]; then
|
||||
__COMP_CACHE_DIR=${__COMP_CACHE_DIR:-${ZDOTDIR:-$HOME}/.cache}
|
||||
if [[ ! -d ${__COMP_CACHE_DIR} ]]; then
|
||||
command mkdir -p "${__COMP_CACHE_DIR}"
|
||||
fi
|
||||
zstyle ':completion:*' use-cache yes
|
||||
zstyle ':completion:*:complete:*' cache-path "${__COMP_CACHE_DIR}"
|
||||
fi
|
||||
|
||||
# host completion
|
||||
_etc_hosts=()
|
||||
_ssh_config_hosts=()
|
||||
_ssh_hosts=()
|
||||
if [[ -r ~/.ssh/config ]] ; then
|
||||
_ssh_config_hosts=(${${(s: :)${(ps:\t:)${${(@M)${(f)"$(<$HOME/.ssh/config)"}:#Host *}#Host }}}:#*[*?]*})
|
||||
fi
|
||||
|
||||
if [[ -r ~/.ssh/known_hosts ]] ; then
|
||||
_ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*})
|
||||
fi
|
||||
|
||||
if [[ -r /etc/hosts ]] && [[ "$NOETCHOSTS" -eq 0 ]] ; then
|
||||
: ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(grep -v '^0\.0\.0\.0\|^127\.0\.0\.1\|^::1 ' /etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}}
|
||||
fi
|
||||
|
||||
local localname
|
||||
localname="$(uname -n)"
|
||||
hosts=(
|
||||
"${localname}"
|
||||
"$_ssh_config_hosts[@]"
|
||||
"$_ssh_hosts[@]"
|
||||
"$_etc_hosts[@]"
|
||||
localhost
|
||||
)
|
||||
zstyle ':completion:*:hosts' hosts $hosts
|
||||
# TODO: so, why is this here?
|
||||
# zstyle '*' hosts $hosts
|
||||
|
||||
# use generic completion system for programs not yet defined; (_gnu_generic works
|
||||
# with commands that provide a --help option with "standard" gnu-like output.)
|
||||
for compcom in cp deborphan df feh fetchipac gpasswd head hnb ipacsum mv \
|
||||
pal stow uname ; do
|
||||
[[ -z ${_comps[$compcom]} ]] && compdef _gnu_generic ${compcom}
|
||||
done; unset compcom
|
||||
|
||||
# see upgrade function in this file
|
||||
compdef _hosts upgrade
|
||||
}
|
||||
__zsh_compl
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
__MATERUS_HM_ZSH=1
|
||||
@@ -0,0 +1,110 @@
|
||||
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
|
||||
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
|
||||
fi
|
||||
|
||||
bindkey -e
|
||||
if [ -n "$EAT_SHELL_INTEGRATION_DIR" ]; then
|
||||
source "$EAT_SHELL_INTEGRATION_DIR/zsh";
|
||||
fi
|
||||
|
||||
export ZSH_DATA_DIR="${XDG_CONFIG_HOME:-"$HOME/.config"}/zsh/data"
|
||||
export ZSH_CONFIG_DIR="${XDG_CONFIG_HOME:-"$HOME/.config"}/zsh/cfg"
|
||||
|
||||
#Check if terminal is fullcolor
|
||||
if zmodload zsh/terminfo && (( "$terminfo[colors]" >= "256" )); then
|
||||
__MATERUS_ZSH_256COLORS="${__MATERUS_ZSH_256COLORS:-1}"; else
|
||||
__MATERUS_ZSH_256COLORS="${__MATERUS_ZSH_256COLORS:-0}";
|
||||
fi
|
||||
|
||||
|
||||
#region Plugins
|
||||
# Clone plugins if not exists
|
||||
[ -d $ZSH_DATA_DIR/plugins/powerlevel10k ] || git clone https://github.com/romkatv/powerlevel10k $ZSH_DATA_DIR/plugins/powerlevel10k
|
||||
[ -d $ZSH_DATA_DIR/plugins/zsh-syntax-highlighting ] || git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_DATA_DIR/plugins/zsh-syntax-highlighting
|
||||
[ -d $ZSH_DATA_DIR/plugins/zsh-history-substring-search ] || git clone https://github.com/zsh-users/zsh-history-substring-search.git $ZSH_DATA_DIR/plugins/zsh-history-substring-search
|
||||
[ -d $ZSH_DATA_DIR/plugins/zsh-autosuggestions ] || git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_DATA_DIR/plugins/zsh-autosuggestions
|
||||
|
||||
source ${ZSH_DATA_DIR}/plugins/powerlevel10k/powerlevel10k.zsh-theme
|
||||
source ${ZSH_CONFIG_DIR}/extra/zinputrc
|
||||
source ${ZSH_CONFIG_DIR}/extra/zshcompletion.zsh
|
||||
|
||||
source ${ZSH_DATA_DIR}/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
||||
source ${ZSH_DATA_DIR}/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh
|
||||
source ${ZSH_DATA_DIR}/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
|
||||
#endregion
|
||||
|
||||
#region SUBSTRING SEARCH
|
||||
history-substring-search-up-prefixed(){
|
||||
HISTORY_SUBSTRING_SEARCH_PREFIXED=1 history-substring-search-up
|
||||
}
|
||||
history-substring-search-down-prefixed(){
|
||||
HISTORY_SUBSTRING_SEARCH_PREFIXED=1 history-substring-search-down
|
||||
}
|
||||
|
||||
zle -N history-substring-search-up-prefixed
|
||||
zle -N history-substring-search-down-prefixed
|
||||
#endregion
|
||||
|
||||
#region Init Variables
|
||||
export SAVEHIST=100000
|
||||
export HISTSIZE=$SAVEHIST
|
||||
export ZSH_PRIVATE=${ZSH_PRIVATE:-0}
|
||||
|
||||
mkdir -p $ZSH_DATA_DIR
|
||||
mkdir -p $ZSH_DATA_DIR/plugins
|
||||
|
||||
# Load config generated by nix
|
||||
[[ -f "$ZSH_DATA_DIR/nix.sh" ]] && source "$ZSH_DATA_DIR/nix.sh"
|
||||
|
||||
setopt HIST_SAVE_NO_DUPS
|
||||
setopt HIST_IGNORE_SPACE
|
||||
setopt HIST_IGNORE_DUPS
|
||||
setopt HIST_IGNORE_ALL_DUPS
|
||||
setopt EXTENDED_HISTORY
|
||||
|
||||
# Private history mode
|
||||
if [[ $ZSH_PRIVATE == 1 ]] then
|
||||
export HISTFILE="/dev/null";
|
||||
unsetopt SHARE_HISTORY;
|
||||
else
|
||||
export HISTFILE="$ZSH_DATA_DIR/zsh_history";
|
||||
setopt SHARE_HISTORY;
|
||||
fi
|
||||
#endregion
|
||||
|
||||
|
||||
#region Bindings
|
||||
bindkey -r "^["
|
||||
bindkey "^[[1;5C" forward-word
|
||||
bindkey "^[[1;5D" backward-word
|
||||
bindkey "^[[1;5A" history-substring-search-up-prefixed
|
||||
bindkey "^[[1;5B" history-substring-search-down-prefixed
|
||||
bindkey "$key[Up]" history-substring-search-up
|
||||
bindkey "$key[Down]" history-substring-search-down
|
||||
bindkey '^[[3~' delete-char
|
||||
bindkey '^[[3;2~' delete-word
|
||||
#endregion
|
||||
|
||||
#region Completions
|
||||
ZSH_COMPDUMP="${ZSH_COMPDUMP:-${XDG_CACHE_HOME:-${HOME}/.cache}/.zcompdump-${HOST}-${ZSH_VERSION}}"
|
||||
autoload -U compinit && compinit -d $ZSH_COMPDUMP
|
||||
#endregion
|
||||
|
||||
#region Functions
|
||||
zsh-private() {
|
||||
ZSH_PRIVATE=1 zsh
|
||||
}
|
||||
|
||||
myip() {
|
||||
wget -qO- https://wtfismyip.com/text
|
||||
}
|
||||
|
||||
speedtest() {
|
||||
curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python3
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
if [[ "$__MATERUS_ZSH_256COLORS" = "1" ]] ; then [[ ! -f ${ZSH_CONFIG_DIR}/p10kcfg/fullcolor.zsh ]] || source ${ZSH_CONFIG_DIR}/p10kcfg/fullcolor.zsh;
|
||||
else [[ ! -f ${ZSH_CONFIG_DIR}/p10kcfg/compatibility.zsh ]] || source ${ZSH_CONFIG_DIR}/p10kcfg/compatibility.zsh;
|
||||
fi
|
||||
Reference in New Issue
Block a user