From 263c8056975a3dbd8cba0df1231588797b8427a4 Mon Sep 17 00:00:00 2001 From: elkowar <5300871+elkowar@users.noreply.github.com> Date: Fri, 8 Oct 2021 16:58:07 +0200 Subject: [PATCH] Fix zsh stuff finally --- nixpkgs/.config/nixpkgs/home.nix | 2 +- nixpkgs/.config/nixpkgs/modules/base.nix | 2 +- profile/.profile | 58 ++++++++++++++++++------ zsh/.config/zsh/.zprofile | 1 + zsh/.config/zsh/.zshrc | 41 +++++++++++++++-- zsh/.config/zsh/abbreviations | 6 +++ zsh/.config/zsh/prompt.zsh | 18 +++++++- 7 files changed, 107 insertions(+), 21 deletions(-) create mode 100644 zsh/.config/zsh/.zprofile create mode 100644 zsh/.config/zsh/abbreviations diff --git a/nixpkgs/.config/nixpkgs/home.nix b/nixpkgs/.config/nixpkgs/home.nix index 68fab93..80f44d5 100644 --- a/nixpkgs/.config/nixpkgs/home.nix +++ b/nixpkgs/.config/nixpkgs/home.nix @@ -31,7 +31,7 @@ base = { enable = true; enableFish = true; - enableZsh = true; + enableZsh = false; includeNiceToHaves = true; includeHaskellDev = true; }; diff --git a/nixpkgs/.config/nixpkgs/modules/base.nix b/nixpkgs/.config/nixpkgs/modules/base.nix index 88f1667..f524485 100644 --- a/nixpkgs/.config/nixpkgs/modules/base.nix +++ b/nixpkgs/.config/nixpkgs/modules/base.nix @@ -115,7 +115,7 @@ in fzf = { - enable = true; + enable = false; enableFishIntegration = cfg.enableFish; enableZshIntegration = cfg.enableZsh; defaultCommand = "rg --files"; diff --git a/profile/.profile b/profile/.profile index 2b7622d..275a050 100644 --- a/profile/.profile +++ b/profile/.profile @@ -1,12 +1,25 @@ -export EDITOR="nvim" -export PATH="/home/leon/.local/bin/scripts:$PATH:/home/leon/.emacs.d/bin/" -export PATH="$HOME/.npm-global/bin:$HOME/intelliJInstall/bin:$PATH:$HOME/.cargo/bin" +if [ -e $HOME/.nix-profile/etc/profile.d/nix.sh ]; then + . $HOME/.nix-profile/etc/profile.d/nix.sh; +fi + + + +export PATH="$HOME/.local/bin/scripts:$PATH" +export PATH="$HOME/.emacs.d/bin/:$PATH" +export PATH="$HOME/.npm-global/bin:$PATH" +export PATH="$HOME/intelliJInstall/bin:$PATH" +export PATH="$HOME/.cargo/bin:$PATH" export PATH="$HOME/.nix-profile/share/applications/:$PATH" -export PATH="/home/leon/.nix-profile/bin/:$PATH" -export PATH="/home/leon/.cpm/bin:$PATH" -export PATH="/home/leon/.local/bin:$PATH" -export PATH="/home/leon/.nimble/bin:$PATH" -export _JAVA_AWT_WM_NONREPARENTING=1 +export PATH="$HOME/.nix-profile/bin/:$PATH" +export PATH="$HOME/.cpm/bin:$PATH" +export PATH="$HOME/.local/bin:$PATH" +export PATH="$HOME/.nimble/bin:$PATH" + + +export EDITOR="$(which nvim)" +export BROWSER="$(which google-chrome-stable)" +export TERMINAL="$(which alacritty)" + export RANGER_LOAD_DEFAULT_RC=FALSE @@ -16,19 +29,26 @@ export FZF_ALT_C_COMMAND="rg --files --null | xargs -0 dirname | sort -u" export LESSHISTFILE="/dev/null" - export XDG_CACHE_HOME="$HOME/.cache" export XDG_CONFIG_HOME="$HOME/.config" +export XDG_DATA_HOME="$HOME/.local/share" + + +# Man pages color support +export LESS_TERMCAP_mb=$'\e[1;32m' +export LESS_TERMCAP_md=$'\e[1;32m' +export LESS_TERMCAP_me=$'\e[0m' +export LESS_TERMCAP_se=$'\e[0m' +export LESS_TERMCAP_so=$'\e[01;33m' +export LESS_TERMCAP_ue=$'\e[0m' +export LESS_TERMCAP_us=$'\e[1;4;31m' + export NNN_PLUG='F:fzopen;S:suedit' -[ "$XDG_CURRENT_DESKTOP" = "KDE" ] || [ "$XDG_CURRENT_DESKTOP" = "GNOME" ] || export QT_QPA_PLATFORMTHEME="qt5ct" - export FREETYPE_PROPERTIES='truetype:interpreter-version=40' export _JAVA_OPTIONS='-Dswing.aatext=true -Dawt.useSystemAAFontSettings=lcd' -if [ -e /home/leon/.nix-profile/etc/profile.d/nix.sh ]; then - . /home/leon/.nix-profile/etc/profile.d/nix.sh; -fi # added by Nix installer + export XDG_DATA_DIRS="$HOME/.nix-profile/share/applications:$HOME/.local/share/applications:/usr/local/share:/usr/share" export LOCALE_ARCHIVE=$(nix-build '' --no-out-link -A glibcLocales)/lib/locale/locale-archive @@ -36,3 +56,13 @@ export LOCALE_ARCHIVE=$(nix-build '' --no-out-link -A glibcLocales)/lib export _JAVA_AWT_WM_NONREPARENTING=1 +command -v opam > /dev/null && eval "$(opam env)" +command -v luarocks > /dev/null && eval "$(luarocks path --lua-version=5.4)" +command -v zoxide > /dev/null && eval "$(zoxide init zsh)" + + + +## Launches tbsm on session start +if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then + tbsm +fi diff --git a/zsh/.config/zsh/.zprofile b/zsh/.config/zsh/.zprofile new file mode 100644 index 0000000..80569c8 --- /dev/null +++ b/zsh/.config/zsh/.zprofile @@ -0,0 +1 @@ +[ -f $HOME/.profile ] && . $HOME/.profile diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc index 895c198..4a45396 100644 --- a/zsh/.config/zsh/.zshrc +++ b/zsh/.config/zsh/.zshrc @@ -1,3 +1,17 @@ + +# history config +HISTSIZE=50000 +SAVEHIST=50000 +HISTFILE="$XDG_CACHE_HOME"/zsh/history +setopt HIST_SAVE_NO_DUPS +setopt HIST_IGNORE_ALL_DUPS +#setopt INC_APPEND_HISTORY +setopt EXTENDED_HISTORY +setopt SHARE_HISTORY + + + +# plugins source ~/.zplug/init.zsh zplug 'zplug/zplug', hook-build:'zplug --self-manage' @@ -6,6 +20,8 @@ zplug "zsh-users/zsh-completions" zplug "Aloxaf/fzf-tab", defer:2 zplug "zsh-users/zsh-history-substring-search", defer:2 zplug "zdharma/fast-syntax-highlighting", defer:2 +zplug "zsh-users/zsh-autosuggestions" +zplug "olets/zsh-abbr" if ! zplug check --verbose; then printf "Install? [y/N]: " @@ -15,16 +31,29 @@ if ! zplug check --verbose; then fi zplug load -eval "$(zoxide init zsh)" +# load more stuff source "$ZDOTDIR/fzf-tab.zsh" -setopt nobeep -setopt HIST_IGNORE_ALL_DUPS +# fzf keybindings +[ -f $HOME/.fzf/shell/key-bindings.zsh ] && . $HOME/.fzf/shell/key-bindings.zsh + + +# some more options +setopt NOBEEP +setopt INTERACTIVE_COMMENTS + + +# ET nvim as manpager +export MANPAGER='nvim +Man! +"set nocul" +"set noshowcmd" +"set noruler" +"set noshowmode" +"set laststatus=0"' + + autoload -Uz colors && colors autoload -Uz promptinit && promptinit +# epic keybinds + my-backward-delete-word() { local WORDCHARS=${WORDCHARS/\//} zle backward-delete-word @@ -35,8 +64,12 @@ bindkey '^H' backward-delete-word bindkey "^[[H" beginning-of-line bindkey "^[[F" end-of-line +bindkey '^[[A' history-substring-search-up +bindkey '^[[B' history-substring-search-down + +# alias alias ls="exa --icons" - +# load prompt source "$ZDOTDIR/prompt.zsh" diff --git a/zsh/.config/zsh/abbreviations b/zsh/.config/zsh/abbreviations new file mode 100644 index 0000000..6348f7d --- /dev/null +++ b/zsh/.config/zsh/abbreviations @@ -0,0 +1,6 @@ +abbr cvim="cd ~/.config/nvim && nvim && cd -" +abbr cnix="cd ~/.config/nixpkgs && nvim && cd -" +abbr cxmonad="cd ~/.xmonad && nvim lib/Config.hs && cd -" +abbr ra="ranger" +abbr cr="cargo run -- " + diff --git a/zsh/.config/zsh/prompt.zsh b/zsh/.config/zsh/prompt.zsh index 56833a0..48167c2 100644 --- a/zsh/.config/zsh/prompt.zsh +++ b/zsh/.config/zsh/prompt.zsh @@ -4,6 +4,21 @@ local __bright_cyan="#8ec07c" local __bright_white="#ebdbb2" local __bright_green="#b8bb26" + +# black magic that reruns prompt whenever the vi mode changes {{{ +function zle-line-init zle-keymap-select { + case $KEYMAP in + vicmd) VI_INDICATOR="N";; + main|viins) VI_INDICATOR="─";; + esac + zle reset-prompt +} +zle -N zle-line-init +zle -N zle-keymap-select +# }}} + + + dir() { local CUTOFF=3 local IFS=/ @@ -29,7 +44,8 @@ git_status() { function _my_prompt() { local exit_code="$?" - echo -n "%F{$__bright_white}╭───" + echo -n "%F{$__bright_white}╭─$VI_INDICATOR─" + #echo -n "%F{$__bright_white}╭───" echo -n "%F{$__bright_cyan}$USER" echo -n "%F{$__bright_white} in" echo -n "%F{$__bright_green} $(dir)"