1
0
mirror of https://github.com/dcarrillo/dotfiles.git synced 2024-11-20 12:11:11 +00:00
dotfiles/.zshrc

178 lines
5.3 KiB
Bash
Raw Permalink Normal View History

2022-11-14 17:58:14 +00:00
#zmodload zsh/zprof
2021-06-17 16:13:12 +00:00
# Enable Powerlevel10k instant prompt.uld stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
2019-07-18 16:45:46 +00:00
# Source Prezto.
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
fi
# ZSH customs
2024-09-27 17:31:30 +00:00
export PATH="${PATH}:${HOME}/bin:${HOME}/.krew/bin:${HOME}/go/bin:${HOME}/.local/bin"
2019-07-18 16:45:46 +00:00
setopt clobber
zstyle ':completion:*' rehash true
zstyle ':completion:*' special-dirs true
2019-07-18 16:45:46 +00:00
2024-01-25 19:21:03 +00:00
# export HISTFILE=~/.zsh_history
# export HISTFILESIZE=100000
# export HISTSIZE=100000
2022-04-10 10:19:30 +00:00
2020-01-23 11:48:30 +00:00
unsetopt correct
unsetopt correctall
DISABLE_CORRECTION="true"
PROMPT_EOL_MARK=''
2020-01-23 11:48:30 +00:00
2019-07-18 16:45:46 +00:00
##### aliases ######
alias atuin_delete='atuin search --delete --search-mode=full-text $1'
alias atuin_search='atuin search --search-mode=full-text $1'
alias bat='bat --style=plain --paging=never --theme=Nord $*'
2024-09-20 08:14:39 +00:00
alias batdiff='bat --style=changes --paging=never --theme=Nord $*'
alias bkpwd='rm -rf ${PWD}.bak ; cp -a $PWD{,.bak}'
2019-07-18 16:45:46 +00:00
alias chromium-socks='chromium --proxy-server=socks://localhost:3000'
2020-03-25 10:08:23 +00:00
alias curlh='curl -sD - -o /dev/null'
alias curlr='curl -o /dev/null -w "\n\nCode: \t%{http_code}\n\nDNS: \t%{time_namelookup}\nConnect:\t%{time_connect}\nStartTransfer:\t%{time_starttransfer} (PreTransfer:%{time_pretransfer})\nTotal: \t%{time_total}\n\n"'
alias disable-hl='ZSH_HIGHLIGHT_MAXLENGTH=0'
alias dkillall='docker rm -f $(docker ps -qa)'
2019-07-18 16:45:46 +00:00
alias duh='du -sch .[!.]* *'
2024-10-12 17:00:57 +00:00
alias export_sso_creds='eval $(aws-export-credentials --env-export)'
alias fdh='fd --hidden --no-ignore --exclude .git'
alias gb="git checkout \$(git branch -avv | fzf +m | awk '{print \$1}')"
alias icat='kitten icat --align=left'
alias idiff='kitten diff'
alias issh='kitten ssh'
alias k=kubectl
2022-11-11 19:01:20 +00:00
alias ls='ls --group-directories-first --color=auto --hyperlink=auto'
alias mknamedvenv='mkvirtualenv $(basename $PWD) -r requirements.txt'
alias neovim=nvim
alias open='xdg-open'
2023-11-28 19:23:04 +00:00
alias rgh="rg --hidden --glob '!.git/'"
2024-10-12 17:00:57 +00:00
alias tf=terraform
alias tfa='terraform apply -auto-approve'
alias tfp='terraform plan'
2022-10-01 11:46:18 +00:00
alias vim=nvim
alias yayU='yay -Suy --noconfirm'
2019-07-18 16:45:46 +00:00
2022-05-22 16:30:46 +00:00
##### Functions to be used from command line #####
dexec () {
local cid
local cmd=("$@")
if [ -z "$1" ]; then
cmd=(bash)
fi
cid=$(docker ps -a | sed 1d | fzf -1 | awk '{print $1}')
[ -n "$cid" ] && docker exec -ti "$cid" "${cmd[@]}"
}
kexec () {
local cid
local cmd=("$@")
if [ -z "$1" ]; then
cmd=(bash)
fi
cid=$(kubectl get pods | sed 1d | fzf -1 | awk '{print $1}')
[ -n "$cid" ] && kubectl exec -ti "$cid" -- "${cmd[@]}"
}
2024-10-23 09:53:44 +00:00
knodes () {
kubectl get node -o json \
| jq -r '.items[] | {
name:.metadata.name,
type:.metadata.labels."beta.kubernetes.io/instance-type",
karpenter:.metadata.labels."karpenter.sh/nodepool",
capacity:.metadata.labels."karpenter.sh/capacity-type",
registered:.metadata.labels."karpenter.sh/registered",
initialized:.metadata.labels."karpenter.sh/initialized",
} | [.name,.type,.karpenter,.capacity,.registered,.initialized] | @tsv'
}
2023-08-24 17:53:08 +00:00
siteinfo () {
2024-06-09 10:19:46 +00:00
local url=$(echo "$1" | sed 's#^https\?://##')
local ip="$(dig +short "$url" | tail -1)"
2023-08-24 17:53:08 +00:00
whois "$ip"
echo "Technology detected for $url with IP $ip"
2024-06-09 10:19:46 +00:00
httpx-toolkit -silent -json -follow-redirects -ip -tech-detect -target "$url" | jq -rc '.tech'
}
2024-06-25 16:00:52 +00:00
##### tilix ####
2019-07-18 16:45:46 +00:00
if [ $TILIX_ID ] || [ $VTE_VERSION ] ; then
2020-05-01 13:40:14 +00:00
source /etc/profile.d/vte.sh
2019-07-18 16:45:46 +00:00
fi
2020-05-01 13:40:14 +00:00
##### default apps #####
2019-07-18 16:45:46 +00:00
2022-10-01 11:46:18 +00:00
export EDITOR='nvim'
export VISUAL='nvim'
2019-07-18 16:45:46 +00:00
export PAGER='less'
##### venvs ######
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/bin/virtualenv
export WORKON_HOME=~/.virtualenvs
2022-11-14 17:58:14 +00:00
source /usr/bin/virtualenvwrapper_lazy.sh
2020-06-17 12:19:06 +00:00
alias workondir='workon $(basename $(pwd))'
2019-07-18 16:45:46 +00:00
##### fzf #####
source /usr/share/fzf/key-bindings.zsh
source /usr/share/fzf/completion.zsh
fzf-file-widget-hidden () {
2022-05-22 16:30:46 +00:00
fd --type f --hidden --follow --exclude .git --exclude .cache | fzf
2019-07-18 16:45:46 +00:00
}
2022-05-22 16:30:46 +00:00
export FZF_DEFAULT_COMMAND="fd --type file --follow"
2022-04-09 11:10:48 +00:00
export FZF_DEFAULT_OPTS="-m --reverse \
--color 'info:#00AAFF,prompt:#FFFFFF,pointer:#00AAFF,hl:#1AE51A,hl+:#1AE51A' \
--tabstop=4"
# --bind 'ctrl-o:execute(xdg-open {})+abort,ctrl-e:execute({})+abort,ctrl-y:execute(echo {} | xclip -selection clipboard -in)+abort'"
2019-07-18 16:45:46 +00:00
export FZF_CTRL_T_OPTS="--no-height --preview '[[ \$(file --mime {}) =~ binary ]] && echo {} is a binary file || pygmentize {} 2> /dev/null | head -500'"
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
bindkey '^P' fzf-file-widget
zle -N fzf-file-widget-hidden
bindkey '^H' fzf-file-widget-hidden
## SSH agent
if [ -z $SSH_AUTH_SOCK ] && [ -S "${XDG_RUNTIME_DIR}/ssh-agent.socket" ]; then
export SSH_AUTH_SOCK="${XDG_RUNTIME_DIR}/ssh-agent.socket"
fi
2019-10-24 17:51:55 +00:00
2022-09-08 15:27:03 +00:00
## direnv
eval "$(direnv hook zsh)"
2024-01-25 19:21:03 +00:00
# Atuin zsh history
2021-01-23 18:38:50 +00:00
2024-01-25 19:21:03 +00:00
eval "$(atuin init zsh)"
2024-09-27 17:31:30 +00:00
# aws cli zsh autocomplete
source /usr/bin/aws_zsh_completer.sh
# custom device
2020-06-12 15:05:11 +00:00
source ~/.zshrc_custom
2021-06-17 16:13:12 +00:00
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
2022-11-14 17:58:14 +00:00
#zprof