Harden .ssh security and templatize shell configs
This commit is contained in:
+166
@@ -0,0 +1,166 @@
|
||||
{{- if eq .chezmoi.os "linux" -}}
|
||||
# Instant prompt for Powerlevel10k
|
||||
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
|
||||
|
||||
# --- Homebrew Initialization ---
|
||||
if [ -f "/home/linuxbrew/.linuxbrew/bin/brew" ]; then
|
||||
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
|
||||
fi
|
||||
{{- end }}
|
||||
|
||||
VI_MODE_SET_CURSOR=true
|
||||
MODE_INDICATOR="%F{yellow}+%f"
|
||||
bindkey -v
|
||||
bindkey 'jk' vi-cmd-mode
|
||||
|
||||
# Visual feedback for vi mode
|
||||
function zle-keymap-select {
|
||||
if [[ $KEYMAP == vicmd ]]; then
|
||||
echo -ne "\e[2 q" # Block
|
||||
else
|
||||
echo -ne "\e[6 q" # Beam
|
||||
fi
|
||||
}
|
||||
zle -N zle-keymap-select
|
||||
echo -ne "\e[6 q" # Start with beam
|
||||
precmd() { echo -ne "\e[6 q" } # Reset to beam before prompt
|
||||
bindkey '^[[A' history-substring-search-up
|
||||
bindkey '^[[B' history-substring-search-down
|
||||
|
||||
export LC_CTYPE=en_GB.UTF-8
|
||||
export LC_ALL=en_GB.UTF-8
|
||||
export LANG=en_GB.UTF-8
|
||||
export EDITOR='/usr/bin/nvim'
|
||||
export MAVEN_OPTS='-Dstyle.color=always'
|
||||
|
||||
# Options
|
||||
setopt AUTO_CD
|
||||
setopt CORRECT
|
||||
setopt HIST_IGNORE_DUPS
|
||||
setopt SHARE_HISTORY
|
||||
|
||||
# History
|
||||
HISTSIZE=10000
|
||||
SAVEHIST=10000
|
||||
HISTFILE=~/.zsh_history
|
||||
|
||||
# to customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
|
||||
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
|
||||
|
||||
export PYENV_ROOT="$HOME/.pyenv"
|
||||
export JDK8_HOME="$HOME/.jdks/jdk-1.8"
|
||||
export JDK21_HOME="$HOME/.jdks/jdk-21"
|
||||
export JDK25_HOME="$HOME/.jdks/jdk-25"
|
||||
export JAVA_HOME="$JDK21_HOME"
|
||||
export GROOVY_HOME="$HOME/devtools/groovy"
|
||||
export M2_HOME="$HOME/devtools/maven"
|
||||
export NODE_ENV=development
|
||||
|
||||
{{- if eq .chezmoi.os "linux" }}
|
||||
export GDK_BACKEND=x11
|
||||
export PNPM_HOME="$HOME/.local/share/pnpm"
|
||||
export PATH="$PNPM_HOME:$HOME/.local/bin:$PATH:$JAVA_HOME/bin:$M2_HOME/bin:$GROOVY_HOME/bin:$PYENV_ROOT/bin:$HOME/.npm-global/bin:/snap/bin"
|
||||
{{- else }}
|
||||
export PATH="$JAVA_HOME/bin:$M2_HOME/bin:$GROOVY_HOME/bin:$PYENV_ROOT/bin:$HOME/.npm-global/bin:/snap/bin:$HOME/.local/bin:/usr/local/bin:/usr/bin"
|
||||
{{- end }}
|
||||
|
||||
typeset -g POWERLEVEL9K_INSTANT_PROMPT=quiet
|
||||
export ZSH="$HOME/.oh-my-zsh"
|
||||
|
||||
plugins=(
|
||||
git
|
||||
vi-mode
|
||||
zsh-autosuggestions
|
||||
zsh-history-substring-search
|
||||
zsh-completions
|
||||
{{- if eq .chezmoi.os "linux" }}
|
||||
fzf-tab
|
||||
{{- end }}
|
||||
zsh-syntax-highlighting
|
||||
)
|
||||
|
||||
{{- if eq .chezmoi.os "linux" }}
|
||||
# fzf-tab settings
|
||||
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'eza -1 --color=always $realpath'
|
||||
zstyle ':fzf-tab:complete:*' fzf-flags --color=fg:1,fg+:2 --height=50%
|
||||
zstyle ':completion:*:descriptions' format '[%d]'
|
||||
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
|
||||
{{- end }}
|
||||
|
||||
if command -v fzf >/dev/null 2>&1; then
|
||||
source <(fzf --zsh)
|
||||
fi
|
||||
|
||||
export FZF_DEFAULT_OPTS="--height 40% --layout=reverse --border --preview 'bat --style=numbers --color=always --line-range :500 {}'"
|
||||
export FZF_CTRL_T_OPTS="--preview 'bat --style=numbers --color=always --line-range :500 {}'"
|
||||
export FZF_ALT_C_OPTS="--preview 'eza --tree --icons --color=always {} | head -200'"
|
||||
|
||||
# General Aliases
|
||||
alias ai='gemini'
|
||||
alias vi=nvim
|
||||
alias g=git
|
||||
alias lg=lazygit
|
||||
alias code="/mnt/c/Users/reazul.ashraf/AppData/Local/Programs/Microsoft\ VS\ Code/bin/code"
|
||||
alias pbcopy='xclip -selection clipboard'
|
||||
alias pbpaste='xclip -selection clipboard -o'
|
||||
|
||||
# --- Gold Standard Tool Mapping ---
|
||||
if command -v eza >/dev/null 2>&1; then
|
||||
alias ls='eza --icons --group-directories-first'
|
||||
alias la='eza --icons -la --group-directories-first --git'
|
||||
alias tree='eza --tree --icons'
|
||||
else
|
||||
alias ls='ls --color=auto'
|
||||
alias la='ls -la'
|
||||
fi
|
||||
|
||||
if command -v bat >/dev/null 2>&1; then alias cat='bat'; fi
|
||||
if command -v batcat >/dev/null 2>&1; then alias cat='batcat'; alias bat='batcat'; fi
|
||||
if command -v fd >/dev/null 2>&1; then alias find='fd'; alias ff='fd'; fi
|
||||
if command -v rg >/dev/null 2>&1; then alias grep='rg'; fi
|
||||
if command -v sd >/dev/null 2>&1; then alias sed='sd'; fi
|
||||
if command -v choose >/dev/null 2>&1; then alias awk='choose'; fi
|
||||
if command -v procs >/dev/null 2>&1; then alias ps='procs'; fi
|
||||
if command -v btm >/dev/null 2>&1; then alias top='btm'; fi
|
||||
if command -v xh >/dev/null 2>&1; then alias curl='xh'; fi
|
||||
if command -v ouch >/dev/null 2>&1; then alias zip='ouch'; alias tar='ouch'; fi
|
||||
if command -v delta >/dev/null 2>&1; then alias diff='delta'; fi
|
||||
|
||||
# Navigation
|
||||
alias ..='cd ..'
|
||||
alias ...='cd ../..'
|
||||
alias ....='cd ../../..'
|
||||
|
||||
# Functions
|
||||
fcd() {
|
||||
local dir
|
||||
dir=$(fd -t d 2>/dev/null | fzf --preview 'eza --tree --icons --color=always {} | head -200') && cd "$dir"
|
||||
}
|
||||
|
||||
alias jdk8home="export JAVA_HOME=$JDK8_HOME"
|
||||
alias jdk21home="export JAVA_HOME=$JDK21_HOME"
|
||||
alias jdk25home="export JAVA_HOME=$JDK25_HOME"
|
||||
|
||||
gsquash() {
|
||||
git reset --soft head~$(git rev-list --count head ^$1)
|
||||
echo "To complete then do, git push --force"
|
||||
}
|
||||
|
||||
source $ZSH/oh-my-zsh.sh
|
||||
|
||||
{{- if eq .chezmoi.os "linux" }}
|
||||
export STARSHIP_DEVICE_COLOR="orange"
|
||||
export STARSHIP_CONFIG=~/.config/starship_linux.toml
|
||||
eval "$(starship init zsh)"
|
||||
alias refresh-vpn='powershell.exe -ExecutionPolicy Bypass -File "C:\Users\reazul.ashraf\scripts\refresh_wsl_vpn.ps1"'
|
||||
{{- end }}
|
||||
|
||||
eval "$(zoxide init --cmd z zsh)"
|
||||
|
||||
# Autosuggestions color
|
||||
export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=cyan'
|
||||
|
||||
# Start in ~
|
||||
cd ~
|
||||
Reference in New Issue
Block a user