Skip to content

Instantly share code, notes, and snippets.

@Dema
Created May 31, 2022 09:16
Show Gist options
  • Save Dema/35bd7a42606dd2328dcc9baeb4e96de8 to your computer and use it in GitHub Desktop.
Save Dema/35bd7a42606dd2328dcc9baeb4e96de8 to your computer and use it in GitHub Desktop.
.zshrc
# if [ -n "$DISPLAY" -a "$TERM" = "xterm" ]; then
# export TERM=xterm-256color
# fi
# Most themes use this option.
setopt promptsubst
bindkey -e
fpath=($HOME/.zsh-completions $fpath)
source ~/.zplugin/bin/zplugin.zsh
zplugin light chrissicool/zsh-256color
zplugin load zdharma/history-search-multi-word
zplugin ice compile"*.lzui" from"notabug"
zplugin load zdharma/zui
zplugin light zdharma/zplugin-crasis
#to be able to use zle reset-prompt in your e.g. sched calls, in presence of zdharma/fast-syntax-highlighting, zsh-users/zsh-syntax-highlighting, zsh-users/zsh-autosuggestions and other plugins that hook up into Zshell by overloading Zle widgets.
zstyle :plugin:history-search-multi-word reset-prompt-protect 1
# Can be "LINES/4" - relative to screen size.
# I like to see a lot of suggestions
zstyle ":history-search-multi-word" page-size "LINES"
zplugin ice as"program" pick"$ZPFX/bin/git-*" make"PREFIX=$ZPFX"
zplugin light tj/git-extras
zplugin ice wait"0" atload"unalias grv" lucid
zplugin snippet OMZ::plugins/git/git.plugin.zsh
zplugin snippet OMZ::lib/git.zsh
zplugin snippet OMZ::lib/completion.zsh
zplugin snippet OMZ::lib/directories.zsh
zplugin snippet OMZ::lib/compfix.zsh
# Conflicts with history search
#zplugin snippet OMZ::lib/key-bindings.zsh
zplugin snippet OMZ::plugins/magic-enter/magic-enter.plugin.zsh
MAGIC_ENTER_OTHER_COMMAND="ls -lFh"
zplugin snippet OMZ::plugins/tmux/tmux.plugin.zsh
zplugin snippet OMZ::plugins/systemd/systemd.plugin.zsh
zplugin snippet OMZ::plugins/safe-paste/safe-paste.plugin.zsh
zplugin snippet OMZ::plugins/common-aliases/common-aliases.plugin.zsh
zplugin light chisui/zsh-nix-shell
zplugin light zsh-users/zsh-autosuggestions
zplugin light zsh-users/zsh-completions
source /home/dema/Sync/dotfiles/zplugin/.zplugin/plugins/tj---git-extras/etc/git-extras-completion.zsh
#THEME
#zplugin ice pick"async.zsh" src"pure.zsh"
#zplugin light sindresorhus/pure
### Agnoster Theme
ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%}!"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[green]%}?"
ZSH_THEME_GIT_PROMPT_CLEAN=""
zplugin snippet OMZ::themes/agnoster.zsh-theme
#Too dark on black terminals
prompt_dir() {
prompt_segment 018 white '%~'
}
# nix-shell: currently running nix-shell
prompt_nix_shell() {
if [[ -n "$IN_NIX_SHELL" ]]; then
if [[ -n $NIX_SHELL_PACKAGES ]]; then
local package_names=""
local packages=($NIX_SHELL_PACKAGES)
for package in $packages; do
package_names+=" ${package##*.}"
done
prompt_segment black yellow "{$package_names }"
elif [[ -n $name ]]; then
local cleanName=${name#interactive-}
cleanName=${cleanName%-environment}
prompt_segment black yellow "{ $cleanName }"
else # This case is only reached if the nix-shell plugin isn't installed or failed in some way
prompt_segment black yellow "nix-shell {}"
fi
fi
}
## Main prompt
build_prompt() {
RETVAL=$?
prompt_status
prompt_nix_shell
prompt_virtualenv
prompt_context
prompt_dir
prompt_git
prompt_bzr
prompt_hg
prompt_end
}
### End
#
# Tracks your most used directories, based on 'frecency'. And its accompanying
# setup code.
zplugin light rupa/z
autoload -Uz compinit
compinit
# Must be the last plugin loaded
#zplugin ice wait"0" atinit"zpcompinit" lucid
zplugin light zdharma/fast-syntax-highlighting
add-zsh-hook precmd _z_precmd
function _z_precmd {
_z --add "$PWD"
}
export EDITOR=nvim
# NixOS
if [ -d /etc/nixos ]; then
export SSH_AUTH_SOCK=$XDG_RUNTIME_DIR/ssh-agent
else
export SSH_AUTH_SOCK=$XDG_RUNTIME_DIR/ssh-agent.socket
fi
autoload -U add-zsh-hook
export HISTFILE=$HOME/.histfile
bindkey '^[[3~' delete-char
bindkey '^[[F' end-of-line
bindkey '^[[H' beginning-of-line
# Make zsh know about hosts already accessed by SSH
zstyle -e ':completion:*:(ssh|scp|sftp|rsh|rsync):hosts' hosts 'reply=(${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) /dev/null)"}%%[# ]*}//,/ })'
alias fd='find . -type d -name'
alias ff='find . -type f -name'
unalias rm
unalias mv
unalias cp
zpl ice atinit'local i; for i in *.zsh; do source $i; done'; zpl light ~/Sync/dotfiles/oh-my-zsh/custom
setopt extendedglob
function get-pr-override() {
PR_NO=$1
HASH=$(curl -sL https://github.com/NixOS/nixpkgs/pull/${PR_NO}.patch \
| head -n 1 | grep -o -E -e "[0-9a-f]{40}")
echo pr${PR_NO} = "import (fetchTarball"
echo " \"\${nixpkgs-tars}${HASH}.tar.gz\")"
echo " { config = config.nixpkgs.config; };"
}
autoload -Uz edit-command-line
zle -N edit-command-line
bindkey "^X^E" edit-command-line
function set-title-precmd() {
printf "\e]2;%s\a" "${PWD/#$HOME/~}"
}
function set-title-preexec() {
printf "\e]2;%s\a" "$1"
}
autoload -Uz add-zsh-hook
add-zsh-hook precmd set-title-precmd
add-zsh-hook preexec set-title-preexec
export ANDROID_SDK_ROOT=~/Android/Sdk/
eval "$(rbenv init -)"
source /home/dema/.config/broot/launcher/bash/br
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment