Ich bin gerade auf ein Macbook Air umgestiegen. Ich habe zsh mit Homebrew installiert, aber wenn ich einen Teil des Codes verwende, den ich (ursprünglich) in meinem .zshrc
hatte , erhalte ich eine Fehlermeldung, die besagt, dass .dircolors was not found
.
Unten ist der fragliche Code:
zstyle ':completion:*' auto-description 'specify: %d'
zstyle ':completion:*' completer _expand _complete _correct _approximate
zstyle ':completion:*' format 'Completing %d'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' menu select=2
eval "$(dircolors -b)"
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*'
zstyle ':completion:*' menu select=long
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
zstyle ':completion:*' use-compctl false
zstyle ':completion:*' verbose true
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
Ist dircolors
nicht mit Mac OS X geliefert? Wie soll ich es installieren?
Aktualisierung:
Wenn ich dircolors direkt auf der Shell ausführe, erhalte ich:
bash: dircolors; command not found
Akzeptierte Antwort:
Der Befehl dircolors
ist spezifisch für GNU Coreutils, daher finden Sie es auf nicht eingebettetem Linux und auf Cygwin, aber nicht auf anderen Unix-Systemen wie OSX. Die generierten Einstellungen in Ihrer .zshrc
sind nicht auf OSX portierbar.
Da Sie die Standardfarben verwenden, können Sie einen leeren String an list-colors
übergeben um Farben in Dateivervollständigungen zu bekommen.
Für Farben mit dem aktuellen ls
Befehl, setzen Sie den CLICOLOR
Umgebungsvariable unter OSX und setzen Sie außerdem LSCOLORS
(Siehe Handbuch für das Format), wenn Sie die Farben ändern möchten.
if whence dircolors >/dev/null; then
eval "$(dircolors -b)"
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
alias ls='ls --color'
else
export CLICOLOR=1
zstyle ':completion:*:default' list-colors ''
fi
Wenn Sie nicht standardmäßige Farben festlegen möchten (dircolors
mit einem Dateiargument), wäre meine Empfehlung, die Ausgabe von dircolors -b ~/.dircolors
fest zu codieren in Ihrer .zshrc
und verwenden Sie diese Einstellungen sowohl für zsh als auch für GNU ls.
LS_COLORS=…
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
if whence dircolors >/dev/null; then
export LS_COLORS
alias ls='ls --color'
else
export CLICOLOR=1
LSCOLORS=…
fi