The user could empty the authorized_keys and break the login of the website, change the shell configuration to break the prompt, and write startup files that zsh reads on every login. The shell configuration and the key are now read-only for the user, and the shell reads its configuration from ~/.zsh, so the files in the home directory are ignored. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
36 lines
1.8 KiB
Shell
36 lines
1.8 KiB
Shell
# History shared between sessions.
|
|
HISTFILE=~/.zsh_history HISTSIZE=10000 SAVEHIST=10000
|
|
setopt share_history hist_ignore_dups hist_ignore_space interactive_comments auto_cd
|
|
|
|
# Completion: menu, case-insensitive, colored. -C skips compaudit, which is slow on
|
|
# Windows and meaningless under MSYS2's noacl mounts (rm ~/.zcompdump after adding completions).
|
|
autoload -Uz compinit && compinit -C
|
|
zstyle ':completion:*' menu select
|
|
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
|
|
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
|
|
|
|
# Emacs keys; Up/Down search history for what is already typed.
|
|
bindkey -e
|
|
autoload -Uz up-line-or-beginning-search down-line-or-beginning-search
|
|
zle -N up-line-or-beginning-search && zle -N down-line-or-beginning-search
|
|
bindkey '^[[A' up-line-or-beginning-search '^[OA' up-line-or-beginning-search
|
|
bindkey '^[[B' down-line-or-beginning-search '^[OB' down-line-or-beginning-search
|
|
|
|
# Prompt: user@host:directory, git branch, exit status of the last command if it failed.
|
|
# A literal '#' as on Linux: zsh's %# would show '%', since this root is not uid 0.
|
|
# The branch is read from .git/HEAD directly: starting git on every prompt is slow on Windows.
|
|
precmd() {
|
|
local d=$PWD head=
|
|
until [[ -e $d/.git || $d == / ]]; do d=${d:h}; done
|
|
[[ -f $d/.git/HEAD ]] && read -r head < $d/.git/HEAD
|
|
[[ $head == 'ref: '* ]] && git_branch=${head#ref: refs/heads/} || git_branch=${head:0:7}
|
|
print -Pn '\e]0;%n@%m: %~\a'
|
|
}
|
|
setopt prompt_subst
|
|
PROMPT='%F{green}%n@%m%f:%F{blue}%~%f${git_branch:+ %5F($git_branch)%f}%(?.. %F{red}[%?]%f)# '
|
|
|
|
alias ls='ls --color=auto' ll='ls -lah' grep='grep --color=auto'
|
|
|
|
# Process monitor: htop does not exist for MSYS2 (its /proc only shows MSYS2 processes).
|
|
# bottom is a native Windows program; winpty lets it draw in the pty, as Server 2016 has no ConPTY.
|
|
alias btm='winpty /ucrt64/bin/btm'
|