1
0
Fork 0
nixos-config/home-manager/zsh/zshrc
Malte Brandy c18bcabd31
WIP
2018-05-31 12:34:48 +02:00

54 lines
1.2 KiB
Bash

if [[ -z "$TMUX" ]] {
session=$(tmux ls | grep -v attached | head -1 | cut -f1 -d:)
if [[ -n $session ]] {
exec tmux attach -t $session;
} else {
exec tmux;
}
}
# Prompt
function default_host () {
H="${HOST}%{%}:"
REPLY=${H/apollo%{%}:/}
REPLY=${REPLY/.olymp.space/}
echo $REPLY
}
function default_user () {
U=${USER}@
REPLY=${U/maralorn@/}
echo $REPLY
}
setopt prompt_subst
autoload -U colors && colors # Enable colors in prompt
PROMPT='%{%F{red}%}$(default_user)$(default_host)%{%F{blue}%}%~%{%}> %{%f%}'
precmd() {
local s=$? c=( $(fc -L -D -l -1) )
if [[ $launched && "${c[2]}" != "0:00" ]] {
eventc command $([[ ${s} == 0 ]] && echo success || echo failure) -d command="\"${c[3,-1]}\"" -d time="\"${c[2]}\"" -d host="\"$HOST\""
} else {
export launched=true;
}
}
alias c=cdr
alias s='sudo systemctl'
alias u='systemctl --user'
alias m=man
alias t="tmux attach"
alias tn="tmux new-session"
alias w="develop-here"
alias ls='exa -lh --git'
autoload -Uz chpwd_recent_dirs cdr add-zsh-hook
add-zsh-hook chpwd chpwd_recent_dirs
zstyle ':chpwd:*' recent-dirs-max 25
if [[ $PWD == "$HOME" ]] {
cd "$(head -n1 ~/.chpwd-recent-dirs | sed s/\\$// | sed s/\'//g)"
}
bindkey '^R' history-incremental-pattern-search-backward