Last active
October 22, 2023 13:25
-
-
Save Millon15/38268866bd65037e112ab9dcc6f5086d to your computer and use it in GitHub Desktop.
Default .zshrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set list of themes to pick from when loading at random | |
# Setting this variable when ZSH_THEME=random will cause zsh to load | |
# a theme from this variable instead of looking in $ZSH/themes/ | |
# If set to an empty array, this variable will have no effect. | |
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" ) | |
# Uncomment the following line to use case-sensitive completion. | |
# CASE_SENSITIVE="true" | |
# Uncomment the following line to use hyphen-insensitive completion. | |
# Case-sensitive completion must be off. _ and - will be interchangeable. | |
# HYPHEN_INSENSITIVE="true" | |
# Uncomment one of the following lines to change the auto-update behavior | |
# zstyle ':omz:update' mode disabled # disable automatic updates | |
# zstyle ':omz:update' mode auto # update automatically without asking | |
zstyle ':omz:update' mode reminder # just remind me to update when it's time | |
# Uncomment the following line to change how often to auto-update (in days). | |
zstyle ':omz:update' frequency 14 | |
# Uncomment the following line if pasting URLs and other text is messed up. | |
# DISABLE_MAGIC_FUNCTIONS="true" | |
# Uncomment the following line to disable colors in ls. | |
# DISABLE_LS_COLORS="true" | |
# Uncomment the following line to disable auto-setting terminal title. | |
# DISABLE_AUTO_TITLE="true" | |
# Uncomment the following line to enable command auto-correction. | |
# ENABLE_CORRECTION="true" | |
# Uncomment the following line to display red dots whilst waiting for completion. | |
# COMPLETION_WAITING_DOTS="true" | |
# Uncomment the following line if you want to disable marking untracked files | |
# under VCS as dirty. This makes repository status check for large repositories | |
# much, much faster. | |
# DISABLE_UNTRACKED_FILES_DIRTY="true" | |
# Uncomment the following line if you want to change the command execution time | |
# stamp shown in the history command output. | |
# You can set one of the optional three formats: | |
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" | |
# or set a custom format using the strftime function format specifications, | |
# see 'man strftime' for details. | |
HIST_STAMPS="dd.mm.yyyy" | |
# Would you like to use another custom folder than $ZSH/custom? | |
# ZSH_CUSTOM=$ZSH/custom | |
# If you come from bash you might have to change your $PATH. | |
# export PATH=$HOME/bin:/usr/local/bin:$PATH | |
# Set name of the theme to load -- if set to "random", it will | |
# load a random theme each time oh-my-zsh is loaded, in which case, | |
# to know which specific one was loaded, run: echo $RANDOM_THEME | |
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes | |
ZSH_THEME="robbyrussell" | |
# User configuration | |
# export MANPATH="/usr/local/man:$MANPATH" | |
# You may need to manually set your language environment | |
# export LANGUAGE=en_US.UTF-8 | |
# export LC_ALL=en_US.UTF-8 | |
# export LANG=en_US.UTF-8 | |
# Preferred editor for local and remote sessions | |
# if [[ -n $SSH_CONNECTION ]]; then | |
# export EDITOR="vim" | |
# else | |
# export EDITOR="mvim" | |
# fi | |
export EDITOR=emacs | |
# Path to your oh-my-zsh installation. | |
export ZSH=$HOME/.oh-my-zsh | |
# # The following lines were added by compinstall | |
# zstyle ':completion:*' completer _expand _complete _ignored _approximate | |
# zstyle :compinstall filename '/home/millon/.zshrc' | |
# | |
# autoload -Uz compinit | |
# compinit | |
# # End of lines added by compinstall | |
# | |
# # Lines configured by zsh-newuser-install | |
# HISTFILE=~/.histfile | |
# HISTSIZE=1000 | |
# SAVEHIST=1000 | |
# setopt autocd extendedglob nomatch | |
# unsetopt beep | |
# bindkey -e | |
# # End of lines configured by zsh-newuser-install | |
# Compilation flags | |
# export ARCHFLAGS="-arch x86_64" | |
# Set personal aliases, overriding those provided by oh-my-zsh libs, | |
# plugins, and themes. Aliases can be placed here, though oh-my-zsh | |
# users are encouraged to define aliases within the ZSH_CUSTOM folder. | |
# For a full list of active aliases, run `alias`. | |
# | |
# Example aliases | |
# alias zshconfig="mate ~/.zshrc" | |
# alias ohmyzsh="mate ~/.oh-my-zsh" | |
### !!! SET MY OWN HOME PATH | |
PATH="$HOME/bin:$HOME/.yarn/bin:$HOME/.docker/bin:$PATH" | |
# gcloud | |
# The next line updates PATH for the Google Cloud SDK. | |
#if [ -f '/home/millon/tmp/google-cloud-sdk/path.zsh.inc' ]; then . '/home/millon/tmp/google-cloud-sdk/path.zsh.inc'; fi | |
# The next line enables shell command completion for gcloud. | |
if [ -f "$HOME/tmp/google-cloud-sdk/completion.zsh.inc" ]; then | |
. "$HOME/tmp/google-cloud-sdk/completion.zsh.inc" | |
fi | |
# symfony console completions | |
if [ -f "$HOME/bin/completion.sh" ]; then | |
. "$HOME/bin/completion.sh" | |
fi | |
# go env | |
export GOPATH=$HOME/dev/go | |
export PATH=$PATH:$GOPATH/bin | |
# rust cargo | |
export PATH=$PATH:$HOME/.cargo/bin | |
# gpg | |
export GPG_TTY=$(tty) | |
# ruby | |
# PATH="$(ruby -r rubygems -e 'puts Gem.user_dir')/bin:$PATH" | |
# brew gcc | |
# export LDFLAGS="-L/home/linuxbrew/.linuxbrew/opt/isl@0.18/lib" | |
# export CPPFLAGS="-I/home/linuxbrew/.linuxbrew/opt/isl@0.18/include" | |
# export PKG_CONFIG_PATH="/home/linuxbrew/.linuxbrew/opt/isl@0.18/lib/pkgconfig" | |
# nvm | |
export NVM_DIR=$HOME/.nvm | |
export NVM_COMPLETION=true | |
export NVM_LAZY_LOAD=true | |
# Which plugins would you like to load? | |
# Standard plugins can be found in ~/.oh-my-zsh/plugins/* | |
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ | |
# Example format: plugins=(rails git textmate ruby lighthouse) | |
# Add wisely, as too many plugins slow down shell startup. | |
plugins=( | |
command-not-found | |
common-aliases | |
compleat | |
composer | |
copyfile | |
docker | |
encode64 | |
extract | |
git | |
gitfast | |
history | |
node | |
npm | |
nvm | |
pip | |
pyenv | |
pylint | |
python | |
sublime | |
urltools | |
vagrant | |
vscode | |
web-search | |
yii2 | |
z | |
zsh-nvm | |
# zsh-better-npm-completion | |
# zsh-syntax-highlighting | |
) | |
source $ZSH/oh-my-zsh.sh | |
### START OF BASH SCRIPTS ### | |
## Colors definitions | |
GREEN='\e[0;32m' | |
RED='\e[0;31m' | |
YELLOW='\e[93m' | |
CYAN='\e[96m' | |
MAG='\e[95m' | |
BLUE='\e[1;34m' | |
## Backup scripts | |
# You have to be in the folder, that contains the directories to backup | |
BPATH='$HOME/backups" # For sucsessful backup you need to be in the folder that you want to backu' | |
TAREXT='tar.xz' | |
abs_name() | |
{ | |
echo $(cd $(dirname $1); pwd)/$(basename $1) # | sed 's/ /\\ /g' | |
} | |
alias abs='abs_name' | |
rel_name() | |
{ | |
if [ -f $1 ]; then | |
pn=$(cd $(dirname $1); pwd)/$(basename $1) | |
pn=$(basename $pn) | |
else | |
pn=$(cd $1; pwd) | |
pn=${pn/%.git*/} | |
pn=$(basename $pn) | |
fi | |
pn=${pn/#./} | |
echo $pn # | sed 's/ /\\ /g' | |
} | |
alias rel='abs_name' | |
tar_backup() | |
{ | |
if [[ ! $1 ]] || ! $(ls $1 1> /dev/null); then | |
echo "Usage: tbak <file|folder to backup> [path to put tarred file|folder]" | |
return 1; | |
fi | |
if [[ ! -d ${BPATH} ]]; then | |
mkdir ${BPATH} | |
fi | |
if [[ ! $2 ]]; then | |
2=$BPATH | |
elif [[ $(ls -ld $2 2> /dev/null | head -c 1) != 'd' ]]; then | |
echo "Bad directory to backup name: $2" | |
return 2; | |
fi | |
pn=$(rel_name "$1") | |
rm -f "$2/${pn}.$TAREXT" | |
tar -cJf "$2/${pn}.$TAREXT" $(abs_name "$1") | |
} | |
alias tbak='tar_backup' | |
backup() | |
{ | |
if [[ ! $1 ]] || ! $(ls $1 1> /dev/null); then | |
echo "Usage: bak <file|folder to backup>" | |
return 1; | |
fi | |
pn=$(rel_name "$1") | |
if [[ ! -e "${BPATH}/$1" ]]; then | |
echo -n "Bakuping to ${BPATH}/$pn.$TAREXT" | |
else | |
echo -n "Rewriting bakup to ${BPATH}/$pn.$TAREXT" | |
fi | |
if [[ ! $2 && -d "$1/.git" ]]; then | |
echo '.git' | |
tar_backup $pn/.git ${BPATH} | |
else | |
echo '*' | |
tar_backup $pn ${BPATH} | |
fi | |
} | |
alias bak='backup' | |
universal_backup() | |
{ | |
if [[ ! $1 ]] || ! $(ls $1 1>/dev/null); then | |
echo "Usage: unibak <file|folder to backup> [\"commit message\"]" | |
return 1; | |
fi | |
if [ -d "$1" -a -d "$1/.git" -a $2 ]; then | |
cd $1 | |
git add --all | |
git commit -m $2 | |
if [[ $(git remote) ]]; then | |
git push | |
fi | |
cd .. | |
fi | |
backup $1 | |
} | |
alias unibak='universal_backup' | |
## Remove script | |
# You have to be in the folder, that contains the directories to remove | |
BIP='$HOME/.local/share/Trash/files/' | |
remove() | |
{ | |
echo "Removing to ${BIP}" | |
for i in $*; do | |
sudo rm -rf ${BIP}$i | |
sudo mv $i ${BIP} | |
done | |
} | |
change_extension() | |
{ | |
if [[ $1 == "-h" || $1 == "--help" || $1 == "?" ]]; then | |
echo "chext –– changes extesions for all files in current folder" | |
echo "Usage: chext OLD_FILE_EXTENSION NEW_FILE_EXTENSION" | |
return; | |
fi | |
for f in *.$1; do | |
mv $f `basename $f .$1`.$2; | |
done; | |
} | |
alias chext='change_extension' | |
git_squash() | |
{ | |
git reset --soft HEAD~${1} | |
git commit --edit -m"$(git log --format=%B --reverse HEAD..HEAD@{1})" | |
} | |
alias gsq='git_squash' | |
git_show_all_commits_belongs_to_the_current_branch() | |
{ | |
if [[ ! $1 ]]; then | |
1='HEAD' | |
fi | |
echo Get start/end branch commits by: git rev-list --simplify-by-decoration -2 $1 | |
arr=( $(git rev-list --simplify-by-decoration -2 $1) ); | |
echo Executing: git log --decorate --pretty=oneline --reverse ${arr[2]}..${arr[1]} | |
git log --decorate --pretty=oneline --reverse ${arr[2]}..${arr[1]} | |
} | |
alias gbc='git_show_all_commits_belongs_to_the_current_branch' | |
### END OF BASH SCRIPTS ### | |
### ALIASES ### | |
# good old aliases | |
# alias 42fc='bash $HOME/42FileChecker/42FileChecker.sh' | |
# alias cb='/usr/bin/osascript -e 'tell application \"System Events\" to tell process \"Terminal\" to keystroke \"k\" using command down' | |
# To enhance your shell experience use better rust-written versions of default utilities: | |
# cargo install exa xh hexyl bat jq tokei fd-find du-dust drill | |
# diff-so-fancy -- not a cargo package | |
# dog -- only from binary on github | |
# pip3 install jc | |
# gem install gist | |
alias http='xh' | |
alias count-lines-of-code='tokei' | |
alias parse-to-json='jc' | |
alias json='jq' | |
alias ls='exa' | |
alias xxd='hexyl' | |
# alias cat='bat' | |
alias ca='bat' | |
alias cloc='tokei' | |
# alias curl='xh' | |
# alias find='fd' | |
# alias dig='dog' | |
# alias diff='diff-so-fancy' | |
# alias http-load-test='drill' | |
# WSL specific aliases | |
if grep icrosoft <(uname -a 2> /dev/null) > /dev/null; then | |
alias phpstorm=phpstorm64.exe | |
fi | |
# Debian specific aliases | |
if grep ebian <(uname -a 2> /dev/null) > /dev/null; then | |
alias gist=gist-paste | |
# start gnome-keyring (wrapper above ssh-agent) | |
# gnome-keyrin allow multiple terminal sessions share same ssh-agent instance | |
sock="/tmp/ssh_auth_sock_env_$RANDOM" | |
errors="/tmp/gnome_keyring_daemon_errors_$RANDOM" | |
/usr/bin/gnome-keyring-daemon --start 1> $sock 2> $errors | |
if [ -s "$errors" ]; then | |
/usr/bin/gnome-keyring-daemon --start 1> $sock 2> $errors | |
fi | |
eval $(cat $sock) | |
export SSH_AUTH_SOCK | |
# GNOME_KEYRING_CONTROL=/mnt/wslg/runtime-dir/keyring | |
# SSH_AUTH_SOCK=/mnt/wslg/runtime-dir/keyring/ssh | |
# # ssh-agent setup. It cannot work with different terminal instances from the box, so I had to write this wrapper script | |
# SSH_AGENT_PID=$(ps -C ssh-agent -o pid= | head -n 1); | |
# if [ -n "$SSH_AGENT_PID" ]; then | |
# export SSH_AGENT_PID | |
# SSH_AUTH_SOCK=$(ls /tmp/ssh*/agent.$(echo "$SSH_AGENT_PID-1" | bc | tail -n 1)) | |
# [ $? -ne 0 ] | |
# && echo 'Cannot determine SSH_AUTH_SOCK value! Try it yourself: SSH_AUTH_SOCK=$(ls /tmp/ssh*/agent.$SSH_AGENT_PID); export $SSH_AUTH_SOCK' | |
# || export SSH_AUTH_SOCK | |
# else | |
# eval $(ssh-agent -s) | |
# fi | |
fi | |
# macOS specific aliases | |
if grep arwin <(uname -a 2> /dev/null) > /dev/null; then | |
export HOMEBREW_PREFIX="$HOME/.brew" | |
export HOMEBREW_CELLAR="$HOME/.brew/Cellar" | |
export HOMEBREW_REPOSITORY="$HOME/homebrew" | |
export MANPATH="$HOME/homebrew/share/man${MANPATH+:$MANPATH}:" | |
export INFOPATH="$HOME/homebrew/share/info:${INFOPATH:-}" | |
export PATH="$HOME/.brew/bin:$HOME/.brew/sbin:$PATH" | |
alias vlc='/Applications/VLC.app/Contents/MacOS/VLC' | |
alias code='/Applications/Visual Studio Code.app/Contents/MacOS/Electron' | |
fi | |
alias zbak='gist -u 38268866bd65037e112ab9dcc6f5086d $HOME/.zshrc' | |
alias ezs='emacs $HOME/.zshrc' | |
alias vzs='vim $HOME/.zshrc' | |
alias czs='code $HOME/.zshrc' | |
alias eg='emacs $HOME/.gitconfig' | |
alias cae='cat -e' | |
alias es='echo $?' | |
alias mk='mkdir -p' | |
alias szs='source $HOME/.zshrc' | |
alias bc='bc -qilw' | |
alias cp='cp -r' | |
alias cl='clear' | |
alias bzs='bat $HOME/.zshrc' | |
alias l='ls -G' | |
alias la='ls -aG' | |
alias lr='ls -RG' | |
alias ll='ls -lagHh --group-directories-first' | |
alias l1='ls -1G' | |
alias lll='ls -lRG' | |
alias ..='cd ..' | |
alias ...='cd ../..' | |
alias gi='git init' | |
alias ga='git add' | |
alias gaa='git add --all' | |
alias gs='git status' | |
alias gc="git commit -S -m '" | |
alias gce='git commit -S --edit' | |
alias gcm='git commit -S --amend' | |
alias gca='git commit -S --amend' | |
alias gch='git checkout' | |
alias gchm='git checkout master' | |
alias gchb='git checkout -b' | |
alias gf='git fetch' | |
alias gcl='git clone --recurse-submodules' | |
alias gls='git ls-files' | |
alias gp='git push' | |
alias gpm='git push origin master' | |
alias gpf='git push -f' | |
alias grm='git rm' | |
alias gsm='git submodule' | |
alias gpu='git push --set-upstream origin $(git symbolic-ref --short -q HEAD)' | |
alias gm='git merge' | |
alias gst='git stash' | |
alias gsst='git stash push --staged' | |
alias grs='git reset' | |
alias grsh='git reset --hard' | |
alias gd='git diff --minimal --ignore-all-space --ignore-blank-lines --src-prefix=current/ --dst-prefix=destination/' | |
alias grst='git restore --staged' | |
alias grb='git rebase' | |
alias gr='git remote' | |
alias gt='git tag' | |
alias gb='git branch' | |
alias grf='git reflog' | |
alias grv='git remote -v' | |
alias gra='git remote add' | |
alias grr='git remote rename' | |
alias grao='git remote add origin' | |
alias gps='git push --set-upstream origin master' | |
alias gl="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative" | |
alias gll='git pull' | |
alias glm='git pull origin master' | |
alias gcf='git config' | |
alias gcfl='git config --list' | |
alias de='docker exec -it' | |
alias dl='docker logs' | |
alias dsys='docker system' | |
alias dc='docker compose' | |
alias dcu='docker compose up' | |
alias dcul='docker compose up -d; docker compose logs -f' | |
alias dce='docker compose exec' | |
alias dcl='docker compose logs' | |
alias dcr='docker compose run' | |
alias dkc='docker container' | |
alias dkv='docker volume' | |
alias docker_clean_images='docker rmi $(docker images -a --filter=dangling=true -q)' | |
alias docker_clean_ps='docker rm $(docker ps --filter=status=exited --filter=status=created -q)' | |
alias docker_prune='docker system prune -a' | |
# Custom fancy startup script | |
if [ $(uname) = "Linux" ]; then | |
cowfiles=( $(ls /usr/share/cowsay/cows/*.cow) ) | |
elif [ $(uname) = "Darwin" ]; then | |
cowfiles=( $(ls $(ls -d $HOMEBREW_CELLAR/cowsay/*)/share/cows/*.cow) ) | |
else | |
cowfiles=() | |
fi | |
if [ ${#cowfiles[@]} != 0 ]; then | |
# to generate .dat files from your fotrune-file filled folder use script below | |
# for file in ~/test/fortune-mod/datfiles/*; do if [[ -f "$file" ]]; then strfile "$file"; fi; done | |
rcowfortune() | |
{ | |
fortune 25% computers 25% linuxcookie 25% wisdom 25% humorists \ | |
| cowsay -f $cowfiles[$(($RANDOM % ${#cowfiles[@]}))] | |
} | |
rcowfortune | |
else | |
fortune 100% ascii-art | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment