myhome/.zshrc

234 lines
8.4 KiB
Bash
Raw Normal View History

# ZSHRC
CONFIG=$HOME/.config
2021-03-22 21:25:52 +01:00
parse_git_branch() {
2022-07-18 20:57:39 +02:00
command=$(git branch \
2024-01-13 12:48:55 +01:00
2>/dev/null |
sed -n -e 's/^\* \(.*\)/\1/p' |
awk 'NF{print $NF}' |
sed 's/)//g' \
2>/dev/null)
2022-07-18 20:57:39 +02:00
[ -z $command ] && echo -e "$ " || echo -e "$command $ "
2021-03-22 21:25:52 +01:00
}
gbranch() {
echo -e "$(git branch "$@")"
}
[ -f /etc/gentoo-release ] && export ZSH="/usr/share/zsh/site-contrib/oh-my-zsh"
[ -f /etc/centos-release ] && export ZSH="$HOME/.oh-my-zsh"
[ -f /etc/debian_version ] && export ZSH="$HOME/.oh-my-zsh"
[[ "$(uname)" == "Darwin" ]] && export ZSH="$HOME/.oh-my-zsh"
2021-03-22 21:25:52 +01:00
HISTFILE=$HOME/.history_zsh
2022-10-16 23:15:07 +02:00
HISTSIZE=10000000
2021-03-22 21:25:52 +01:00
SAVEHIST=10000000
autoload -U colors && colors
autoload bashcompinit && bashcompinit
2021-03-22 21:25:52 +01:00
setopt PROMPT_SUBST
PS1='%(!.%{$fg_bold[red]%}.%{$fg_bold[green]%}%n@)%m %{$fg_bold[blue]%}%(!.%1~.%~) $(parse_git_branch)%{$reset_color%}'
2024-01-13 12:48:55 +01:00
plugins=(rake ruby vagrant knife knife_ssh kitchen)
2021-03-22 21:25:52 +01:00
ZSH_DISABLE_COMPFIX=true
source $ZSH/oh-my-zsh.sh
2024-01-13 12:48:55 +01:00
[ -d $CONFIG/zsh/zsh-autosuggestions ] && source $CONFIG/zsh/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh &>>/dev/null
[ -d $CONFIG/zsh/zsh-syntax-highlighting ] && source $CONFIG/zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh &>>/dev/null
[ -d $CONFIG/zsh/zsh-command-time ] && source $CONFIG/zsh/zsh-command-time/command-time.plugin.zsh &>>/dev/null
[ -d $CONFIG/zsh/aws ] && source $CONFIG/zsh/aws/aws.plugin.zsh &>>/dev/null
[ -d $CONFIG/zsh/azure-cli ] && source $CONFIG/zsh/azure-cli/az.completion &>>/dev/null
[ -f $HOME/.password ] && source $HOME/.password
[ -f $CONFIG/fzf/shell/key-bindings.zsh ] && source $HOME/.config/fzf/shell/key-bindings.zsh
2021-03-22 21:25:52 +01:00
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
FPATH=/usr/local/share/zsh/site-functions:$FPATH
2022-05-24 02:09:48 +02:00
# Configuration of command-time
# If command execution time above min. time, plugins will not output time.
ZSH_COMMAND_TIME_MIN_SECONDS=10
ZSH_COMMAND_TIME_MSG="Execution time: %s sec"
ZSH_COMMAND_TIME_EXCLUDE=(ranger git nvim fzf vim mcedit v ssh lg lazygit tmux)
2022-05-24 02:09:48 +02:00
2021-03-22 21:25:52 +01:00
export GPG_TTY=$(tty)
export TERM=xterm-256color
2021-03-22 21:25:52 +01:00
export SHELL=/bin/bash
export GTK_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
export QT_IM_MODULE=ibus
export _JAVA_AWT_WM_NONREPARENTING=1
export CCACHE_DIR="/usr/ccache"
export LC_ALL="en_US.UTF-8"
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
2024-10-06 01:47:08 +02:00
export BROWSER=$HOME/.local/bin/browser-x
2021-03-22 21:25:52 +01:00
export FZF_DEFAULT_OPTS='--height 40% --layout=reverse'
export EIX_LIMIT_COMPACT=0
export TERMINAL="st"
export QT_SCALE_FACTOR=1.5
2023-02-19 12:22:53 +01:00
# Declerating the PATHs
unset PATH
export PATH=/bin:$PATH
export PATH=/usr/bin:$PATH
export PATH=/usr/sbin:$PATH
export PATH=/sbin:$PATH
export PATH=/usr/local/bin:$PATH
export PATH=$HOME/go/bin:$PATH
export PATH=$HOME/golang/bin:$PATH
export PATH=$HOME/.local/bin:$PATH
export PATH=$HOME/node_modules/.bin:$PATH
export GOPATH=$HOME/golang
export PATH=$PATH:$HOME/.gem/ruby/2.6.0/bin
2024-04-13 22:21:56 +02:00
export PATH=$PATH:$HOME/.cargo/bin
2024-10-06 01:47:23 +02:00
[ -d $HOME/git/fortigate/bin ] && export PATH=$HOME/git/fortigate/bin:$PATH
2023-02-19 12:22:53 +01:00
2022-11-18 13:05:38 +01:00
# History
2021-03-22 21:25:52 +01:00
export HISTTIMEFORMAT="%F %T "
2022-01-06 01:02:25 +01:00
2022-08-01 18:51:13 +02:00
# Export for WSL
if [[ "$(uname -sr)" =~ "Microsoft" ]]; then
export GOROOT=/usr/lib/go
fi
# Work
2024-01-04 08:17:23 +01:00
alias ansible-lint-work='GIT_SSH_COMMAND="ssh -i ~/.ssh/work/id_rsa" ansible-lint'
alias ansible-galaxy-work='GIT_SSH_COMMAND="ssh -i ~/.ssh/work/id_rsa" ansible-galaxy'
alias ssh-work="ssh -i ~/.ssh/work/id_rsa"
alias rsyncwork="rsync -h --progress -e 'ssh -i ~/.ssh/work/id_rsa'"
alias git-work='GIT_SSH_COMMAND="ssh -i ~/.ssh/work/id_rsa" git'
2024-05-12 01:51:55 +02:00
alias git-commit-work="git commit --author='Marcin Woźniak <marcin.wozniak@wundermanthompson.com>'"
# Alias ssh
alias ssh-restore="cp -rv ~/ssh-mega/config ~/.ssh/ ; ssh-permissions"
alias ssh-backup="cp -rv ~/.ssh/config ~/ssh-mega/"
2023-02-25 16:12:31 +01:00
# Alias and Export Gentoo
alias svm="sudo $EDITOR /etc/portage/make.conf"
alias svr="sudo $EDITOR /etc/portage/repos.conf"
alias svp="sudo $EDITOR /etc/portage/package.use"
alias sva="sudo $EDITOR /etc/portage/package.accept_keywords"
alias emerge="sudo emerge"
alias mpv="__NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0 __GLX_VENDOR_LIBRARY_NAME=nvidia __GL_SYNC_TO_VBLANK=0 mpv --vo=x11 --hwdec=no --ytdl-raw-options="yes-playlist=" --no-resume-playback --ytdl-format='bestvideo[height<=?1080]+bestaudio/best'"
alias code="vscodium-bin"
alias pl="setxkbmap pl"
alias feh="feh --edit --scale-down"
alias graphic-card="glxinfo|egrep 'OpenGL vendor|OpenGL renderer'"
alias mylaptop-components="inxi -Fxz"
alias update_time="sudo ntpdate -b -u vega.cbk.poznan.pl"
2023-02-25 16:12:31 +01:00
# Alias and Export for Mac
2022-01-06 01:02:25 +01:00
if [[ "$(uname)" == "Darwin" ]]; then
2022-07-18 21:04:13 +02:00
# Resolve problem with GOPATH
# https://stackoverflow.com/questions/66284870/go-get-not-downloading-to-src-folder
2023-01-28 12:58:39 +01:00
export GO111MODULE=on
2022-07-18 21:04:13 +02:00
# Other export
2023-12-17 15:04:47 +01:00
export OPENSSLVER=$(ls "/opt/homebrew/Cellar/openssl@3/" |
sort |
grep -iE '[0-9]+\.[0-9]+\.' |
tail -n1)
export PATH="/opt/homebrew/Cellar/openssl@3/$OPENSSLVER/bin:$PATH"
export PATH="/opt/homebrew/bin:$PATH"
2023-12-17 15:04:47 +01:00
export LDFLAGS="-L/opt/homebrew/Cellar/openssl@3/$OPENSSLVER/lib"
export CPPFLAGS="-I/opt/homebrew/Cellar/openssl@3/$OPENSSLVER/include"
export PKG_CONFIG_PATH="/opt/homebrew/openssl@3/$OPENSSLVER/lib/pkgconfig"
2022-10-16 23:16:20 +02:00
export GOROOT="$(brew --prefix golang)/libexec"
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin
2022-01-06 01:02:25 +01:00
2022-11-18 12:28:57 +01:00
export PYTHONVERSION=$(ls -la /opt/homebrew/opt/ |
grep -iEo 'python@.* ->' |
2024-01-13 12:48:55 +01:00
sed 's/ ->//g' |
2022-11-18 12:28:57 +01:00
sort |
tail -n1 |
sed 's/python@//g')
export PATH=$PATH:$HOME/Library/Python/$PYTHONVERSION/bin
export PATH=$PATH:/usr/local/opt/python@$PYTHONVERSION/Frameworks/Python.framework/Versions/$PYTHONVERSION/bin
export PATH="$(brew --prefix python@$PYTHONVERSION)/bin:$PATH"
alias python3='/opt/homebrew/bin/python$PYTHONVERSION'
alias pip3='/opt/homebrew/bin/pip$PYTHONVERSION'
alias python='/opt/homebrew/bin/python$PYTHONVERSION'
alias pip='/opt/homebrew/bin/pip$PYTHONVERSION'
alias sed='gsed'
alias zcat='gzcat'
alias date='gdate'
2022-10-16 23:17:32 +02:00
2022-01-06 01:02:25 +01:00
alias lsblk="diskutil list"
2024-11-03 16:44:51 +01:00
alias Update="$HOME/.local/bin/Update-pkg; brew update; brew upgrade; brew upgrade --greedy; sudo softwareupdate -i -a -R"
2022-07-18 21:04:13 +02:00
alias ls="ls -Gh"
2023-02-25 16:12:31 +01:00
alias mpv="mpv --ytdl-raw-options="yes-playlist=" --no-resume-playback --ytdl-format='bestvideo[height<=?1080]+bestaudio/best'"
2022-07-18 23:23:33 +02:00
alias code="open -a 'Visual Studio Code'"
2023-02-16 22:54:59 +01:00
alias xclip="pbcopy"
2023-05-11 23:28:36 +02:00
alias mtr="sudo /opt/homebrew/opt/mtr/sbin/mtr"
alias sleep-lid-off="sudo pmset -b sleep 0; sudo pmset -b disablesleep 1"
alias sleep-lid-on="sudo pmset -b sleep 5; sudo pmset -b disablesleep 0"
2024-11-03 16:45:10 +01:00
alias restart-network-share="sudo pkill -i netauthsysagent"
2022-11-18 12:28:57 +01:00
2023-06-17 17:10:40 +02:00
# Terraform
export TFENV_ARCH=amd64
export TFENVVERSION=$(ls -la /opt/homebrew/Cellar/tfenv/ |
grep -iEo '[0-9]\.[0-9]\.[0-9]' |
sort |
2024-01-13 12:48:55 +01:00
tail -n1)
2023-06-17 17:10:40 +02:00
export TFVERSION=$(ls -la /opt/homebrew/Cellar/tfenv/*/versions |
grep -iEo '[0-9]\.[0-9]\.[0-9]' |
sort |
2024-01-13 12:48:55 +01:00
tail -n1)
2023-06-17 17:10:40 +02:00
export PATH=$PATH:/opt/homebrew/Cellar/tfenv/$TFENVVERSION/versions/$TFVERSION/
2024-10-06 01:47:56 +02:00
unset BROWSER
2022-01-06 01:02:25 +01:00
fi
2022-02-22 11:18:32 +01:00
# Setting the right editor
2024-01-13 12:48:55 +01:00
if which nvim >/dev/null 2>&1; then
export VISUAL='nvim -u $HOME/.vimrc'
export EDITOR='nvim -u $HOME/.vimrc'
else
export VISUAL='vim -u $HOME/.vimrc-def'
export EDITOR='vim -u $HOME/.vimrc-def'
fi
2023-02-19 12:28:21 +01:00
2023-02-25 16:12:31 +01:00
# Vim
2023-02-19 12:28:21 +01:00
alias vimc="$EDITOR $HOME/.vimrc"
2023-02-25 16:12:31 +01:00
alias v="$EDITOR -p"
alias vim="$EDITOR -p"
# Commands
2023-07-10 06:09:30 +02:00
alias traceroute="mtr"
2023-02-27 18:38:24 +01:00
alias rsync="rsync -h --progress"
2023-02-25 16:12:31 +01:00
alias lg="lazygit"
2023-04-11 10:21:08 +02:00
alias ldocker="lazydocker"
2023-02-19 12:28:21 +01:00
alias ls="ls -h --color=auto"
alias ll='ls -lha'
2023-02-25 16:12:31 +01:00
alias r="ranger"
2023-02-19 12:28:21 +01:00
alias cp='cp -v'
alias mv='mv -v'
2023-02-25 16:12:31 +01:00
alias cal="cal -3"
alias denpl="trans en:pl"
alias dplen="trans pl:en"
2023-02-19 12:28:21 +01:00
alias myip="curl ipinfo.io/ip"
alias changefont="figlet"
2023-02-25 16:12:31 +01:00
# Others
alias channel-check='sudo iwlist wlan0 scan | egrep -i "essid|frequency"'
2023-02-19 12:28:21 +01:00
alias newswork="newsboat --url=$HOME/.config/newsboat/urlswork"
alias aria2c="aria2c --seed-time=0 --disable-ipv6 --max-upload-limit=1k"
alias irc="ssh mikrus -t 'screen -r'"
2024-09-09 21:48:28 +02:00
alias neofetch=fastfetch
# GoLang
2023-12-28 13:42:26 +01:00
alias go-mod="go mod edit -go $(go version | grep -oE 'go[0-9]*\.[0-9]*\.[0-9]*' | sed 's/go//g'); go get -u; go mod verify; go get -x -v; go mod verify; go mod tidy"
2023-02-19 12:28:21 +01:00
2023-02-25 16:12:31 +01:00
# Resolve problem with - zsh: no matches found
2022-02-22 11:18:32 +01:00
setopt +o nomatch
2022-04-28 14:01:35 +02:00
2022-11-18 13:05:38 +01:00
# Error with icu
export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
2024-10-30 21:22:52 +01:00
# Security changes made in High Sierra that are breaking lots of Python things that use fork()
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
2023-02-25 16:12:31 +01:00
# Error with Delinea - Linux
[ -f "/etc/ssl/certs/ca-certificates.crt" ] && export REQUESTS_CA_BUNDLE='/etc/ssl/certs/ca-certificates.crt'