dotfiles/.zshrc

145 lines
2.9 KiB
Bash
Executable File

#!/bin/zsh
HISTSIZE=10000
SAVEHIST=10000
HISTFILE=~/.histfile
gpg-connect-agent updatestartuptty /bye &> /dev/null
export GPG_TTY=$(tty)
SSH_AUTH_SOCK="/run/user/$(id -u)/gnupg/S.gpg-agent.ssh"
export SSH_AUTH_SOCK
gpgconf --launch gpg-agent
# opam configuration
[[ ! -r /home/trimill/.opam/opam-init/init.zsh ]] || source /home/trimill/.opam/opam-init/init.zsh > /dev/null 2> /dev/null
eval $(opam env)
setopt extendedglob
bindkey -e
tabs 4
autoload -U compinit
compinit
autoload -U up-line-or-beginning-search
autoload -U down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
bindkey "^[[A" up-line-or-beginning-search
bindkey "^[[B" down-line-or-beginning-search
bindkey "^[[1;5C" forward-word
bindkey "^[[1;5D" backward-word
autoload -U colors && colors
setopt promptsubst
man() {
env \
LESS_TERMCAP_md=$'\e[1;36m' \
LESS_TERMCAP_me=$'\e[0m' \
LESS_TERMCAP_se=$'\e[0m' \
LESS_TERMCAP_so=$'\e[1;92m' \
LESS_TERMCAP_ue=$'\e[0m' \
LESS_TERMCAP_us=$'\e[1;35m' \
man "$@"
}
#
# Plugins
#
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
#
# Prompt
#
function prompt_char {
if [ $UID -eq 0 ]; then echo "#"; else echo "$"; fi
}
function git_prompt_info() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$ZSH_THEME_GIT_PROMPT_SUFFIX"
}
PROMPT='%(!.%F{9}.%F{10})%n: %F{15}%c%F{12}$(git_prompt_info)%F{12}$(prompt_char)%F{15} '
PROMPT2='%_%F{12}:%F{15} '
ZSH_THEME_GIT_PROMPT_PREFIX="%F{13} ["
ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%}"
RPROMPT='[%(?.%F{10}.%F{9})%?%F{15}]'
#
# Window title
#
function precmd () {
printf "\e]0;%s\a" "$(basename "$PWD")$ zsh"
}
function preexec () {
printf "\e]0;%s\a" "$(basename "$PWD")$ $1"
}
#
# Aliases
#
alias ..="cd .."
alias ~="cd ~"
# Confirm before copy
alias cp="cp -i"
# add color
alias ccat='highlight --out-format=ansi'
# shorten commands
LSARGS='-hN --color=auto --group-directories-first'
alias ls="ls $LSARGS"
alias ll="ls -l $LSARGS"
alias lla="ls -lA $LSARGS"
alias mkd='mkdir -pv'
# shortcuts
alias ..='cd ..'
# pacman tools
alias sp='sudo pacman'
# shorten python
alias py='python'
# restart shell without open/close
alias reloadsh='exec $SHELL'
# print the time in different formats
alias timestamp='date +"%Y-%m-%dT%H.%M.%S"'
# git commands
alias git-pullall="ls | xargs -I{} git -C {} pull"
alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
# youtube-dl
alias ytdl="youtube-dl -f bestvideo+bestaudio"
alias ytdl-a="youtube-dl --extract-audio --audio-format=mp3"
# ssh tunneling
alias ssht="ssh -D 1080"
alias irc="ssh -t apiaceae tmux attach -t weechat"
alias firefox=librewolf
alias e="emacs -nw"
#
# Todo
#
todomsg=$(todo)
[ "$todomsg" != "" ] && printf "TODO: \n%s\n" "$todomsg"
return 0
# Load Angular CLI autocompletion.
source <(ng completion script)