1
0
Fork 0
nixos-config/home-manager/roles/zsh/zshrc
2021-03-04 10:47:30 +01:00

65 lines
2 KiB
Bash

if [[ -n "$SSH_CONNECTION" && -z "$TMUX" ]] {
exec mytmux
}
if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then
exec sway
fi
mkdir -p /var/run/user/$UID/tmp/downloads
setopt prompt_subst
autoload -U colors && colors # Enable colors in prompt
alias nom-build-remote="nom-build --builders '@/etc/nix/machines' --max-jobs 0"
alias nix-build-remote="nix-build --builders '@/etc/nix/machines' --max-jobs 0"
alias nixpkgs-review-pr-remote='nixpkgs-review pr --build-args "--builders @/etc/nix/machines --max-jobs 0"'
alias nixpkgs-review-rev-remote='nixpkgs-review rev --build-args "--builders @/etc/nix/machines --max-jobs 0"'
alias cat=bat
alias accounting='hledger -f ~/git/buchhaltung/buchhaltung.ledger ui -- --watch --theme=terminal -T -E'
alias o=xdg-open
alias sudo='sudo -A'
alias s='sudo -A systemctl'
alias u='systemctl --user'
alias m=man
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 100
if [[ $PWD == "$HOME" ]] {
cd "$(head -n1 ~/.chpwd-recent-dirs | sed s/\\$// | sed s/\'//g)"
}
fzf-history-search() {
LBUFFER=$( history | sed -E 's/ *[0-9]*\*? *//' | fzf +s --tac | sed -E 's/\\/\\\\/g')
zle redisplay
}
zle -N fzf-history-search
bindkey '^R' fzf-history-search
fzf-directory-history-search() {
LBUFFER=$( sed "s/\\$//;s/'//g" ~/.chpwd-recent-dirs | fzf +s | sed -E 's/\\/\\\\/g;s/^/cd /')
zle redisplay
}
zle -N fzf-directory-history-search
bindkey '^T' fzf-directory-history-search
fzf-directory-search() {
LBUFFER=$( fd -t d | fzf | sed -E 's/\\/\\\\/g;s/^/cd /')
zle redisplay
}
zle -N fzf-directory-search
bindkey '^S' fzf-directory-search
fzf-vim-search() {
LBUFFER=$( fd -t f | fzf | sed -E 's/\\/\\\\/g;s/^/vim /')
zle redisplay
}
zle -N fzf-vim-search
bindkey '^V' fzf-vim-search
fzf-git-checkout() {
LBUFFER=$( git branch --list | fzf | sed -E 's/ \* //;s/^/git checkout /')
zle redisplay
}
zle -N fzf-git-checkout
bindkey '^G' fzf-git-checkout