dotfiles/.zshrc

121 lines
2.3 KiB
Bash
Raw Normal View History

2023-03-16 00:28:53 +00:00
#!/bin/zsh
HISTSIZE=10000
SAVEHIST=10000
HISTFILE=~/.histfile
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 "$@"
}
[ $NOEXIT ] && alias exit="echo Exiting is disabled"
#
# 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}]'
#
# 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
#
# Todo
#
todomsg=$(todo)
[ "$todomsg" != "" ] && printf "TODO: \n%s\n" "$todomsg"
return 0