-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzsh-setup.html
More file actions
117 lines (98 loc) · 4.54 KB
/
zsh-setup.html
File metadata and controls
117 lines (98 loc) · 4.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Zsh System-Wide Setup</title>
<style>
body { font-family: -apple-system, sans-serif; max-width: 800px; margin: 2em auto; padding: 0 1em; line-height: 1.6; color: #222; }
h1 { border-bottom: 2px solid #333; padding-bottom: 0.3em; }
h2 { margin-top: 2em; color: #444; }
pre { background: #f4f4f4; border: 1px solid #ddd; border-radius: 4px; padding: 1em; overflow-x: auto; }
code { background: #f4f4f4; padding: 0.2em 0.4em; border-radius: 3px; }
.file-path { font-weight: bold; color: #1a5276; }
table { border-collapse: collapse; width: 100%; margin: 1em 0; }
th, td { border: 1px solid #ddd; padding: 0.5em 1em; text-align: left; }
th { background: #f0f0f0; }
</style>
</head>
<body>
<h1>Zsh System-Wide Setup</h1>
<p>Configuration applied to both <strong>tuxlibre</strong> and <strong>minime</strong>.</p>
<h2>Installed Packages</h2>
<table>
<tr><th>Package</th><th>Purpose</th></tr>
<tr><td>zsh</td><td>Z Shell</td></tr>
<tr><td>zsh-common</td><td>Architecture-independent zsh files</td></tr>
<tr><td>zsh-autosuggestions</td><td>Fish-like autosuggestions based on history</td></tr>
<tr><td>zsh-syntax-highlighting</td><td>Fish-like syntax highlighting at the prompt</td></tr>
</table>
<p>Install command:</p>
<pre>apt install zsh zsh-autosuggestions zsh-syntax-highlighting</pre>
<h2>Modified Files</h2>
<h3>1. <span class="file-path">/etc/zsh/zshenv</span></h3>
<p>Added two lines at the end to source a local override file (not managed by the package manager, survives upgrades):</p>
<pre># Source local overrides (not managed by package manager)
[[ -f /etc/zsh/zshenv.local ]] && source /etc/zsh/zshenv.local</pre>
<h3>2. <span class="file-path">/etc/zsh/zshenv.local</span> (new file, not package-managed)</h3>
<p>Suppresses the zsh new-user wizard for users who don't have a <code>~/.zshrc</code>:</p>
<pre>zsh-newuser-install() { :; }</pre>
<h3>3. <span class="file-path">/etc/zsh/zshrc</span> (full replacement)</h3>
<p>Complete system-wide interactive shell configuration:</p>
<pre># Initialize completion system
autoload -Uz compinit && compinit
ZSH_AUTOSUGGEST_STRATEGY=(match_prev_cmd history completion)
# GNUstep environment
[ -f /System/Library/Makefiles/GNUstep.sh ] && source /System/Library/Makefiles/GNUstep.sh
source /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh
source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
# Color ls output
export CLICOLOR=1
alias ls='ls --color=auto'
# Use fish-style command history
HISTFILE=~/.zsh_history # Location of history file
HISTSIZE=10000 # Number of lines kept in memory
SAVEHIST=10000 # Number of lines saved to file
# Options for fish-like behavior
setopt hist_ignore_dups # Don't record duplicate lines
setopt hist_reduce_blanks # Remove unnecessary blanks
setopt inc_append_history # Save each command as soon as it's run
setopt share_history # Share history across all zsh sessions
setopt extended_history # Add timestamps to history
setopt hist_find_no_dups # Skip duplicate entries during search
# Fish-style up-arrow history search (per command line input)
autoload -Uz up-line-or-beginning-search
autoload -Uz 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 # Up arrow
bindkey "^[[B" down-line-or-beginning-search # Down arrow
# Load color module
autoload -U colors && colors
# Enable prompt substitution
setopt PROMPT_SUBST
local user_color='2'
local host_color='fg'
local path_color='2'
# Git info function
function git_info() {
if ! command -v git &>/dev/null; then
return 1
fi
if ! git rev-parse --is-inside-work-tree &>/dev/null; then
return 1
fi
local branch=$(git symbolic-ref --short HEAD 2>/dev/null)
if [[ -z "$branch" ]]; then
branch=$(git describe --tags --always 2>/dev/null)
fi
echo "%F{$host_color}($branch)%f"
}
PROMPT="%F{$user_color}%n%f@%F{$host_color}%m%f %F{$path_color}%~\$(git_info)%f %# "</pre>
<h2>Notes</h2>
<ul>
<li><code>/etc/zsh/zshenv</code> and <code>/etc/zsh/zshrc</code> are dpkg conffiles — on package upgrade, dpkg will prompt before overwriting local changes.</li>
<li><code>/etc/zsh/zshenv.local</code> is not owned by any package and will never be touched by upgrades. This is the safe place for local overrides.</li>
<li>No per-user <code>~/.zshrc</code> is needed — the system-wide config handles everything and the wizard is suppressed.</li>
</ul>
</body>
</html>