You are not logged in.

#1 2023-09-08 20:06:22

b42
Member
Registered: 2023-07-20
Posts: 203

[SOLVED]zshrc in Arch Install

I like the colors zsh provides during the install process when I am on live Arch USB, I want to use them on my setup, where can I find the configuration file for that to take to my USB and then use it on my main machine? I only need the lines for the colors though...

Last edited by b42 (2023-10-16 14:13:02)

Offline

#2 2023-09-08 20:08:56

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,661

Re: [SOLVED]zshrc in Arch Install

Afair the iso simply uses https://archlinux.org/packages/extra/an … sh-config/ - you can use that as base for your own config (there's a lot of debian and ancient zsh version related stuff in there)
The global zshrc resides in in /etc/zsh

Edit: clumsy language.

Last edited by seth (2023-09-08 20:09:32)

Offline

#3 2023-09-08 20:48:13

b42
Member
Registered: 2023-07-20
Posts: 203

Re: [SOLVED]zshrc in Arch Install

seth wrote:

Afair the iso simply uses https://archlinux.org/packages/extra/an … sh-config/ - you can use that as base for your own config (there's a lot of debian and ancient zsh version related stuff in there)
The global zshrc resides in in /etc/zsh

Edit: clumsy language.

damn there are almost 4000 lines.

Which one is to get the colors for when I do cd / then press tab and it shows me available options where I can cd and it differentiates those options according to the type of file/dir. If it is blue I can know it is a dir.

Offline

#4 2023-09-08 20:54:26

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,661

Offline

#5 2023-09-09 07:49:19

b42
Member
Registered: 2023-07-20
Posts: 203

Re: [SOLVED]zshrc in Arch Install

this is colors for ls output

I am looking for a solution specifically for cd output (when I press a tab and it shows me available options where it is possible to cd)

Offline

#6 2023-09-09 08:19:36

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,661

Re: [SOLVED]zshrc in Arch Install

Did you actually try to apply the dircolors?
Why would the zsh autocompletion use a different set of colors?

Offline

#7 2023-09-09 12:58:57

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,483
Website

Re: [SOLVED]zshrc in Arch Install

b42 wrote:

... I do cd / then press tab and it shows me available options where I can cd and it differentiates those options according to the type of file/dir. If it is blue I can know it is a dir.

Ah, wut??  Those completion options should *only* be directories, otherwise your tab completion is broken.  You can't cd into a file.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#8 2023-09-09 13:21:08

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,661

Re: [SOLVED]zshrc in Arch Install

I assume he meant that as an example, but fwwi, you'll also oc. get  symlinks and dirs w/ the sticky bit indicated which will get the output a bit more colorful.

A mild pitfall might be that the grml config will not catch any LS_COLORS set later in the (local) zsh, you'll need eg. some explicit

[ -e $HOME/.config/dircolors ] && eval $(dircolors -b $HOME/.config/dircolors) # set your private LS_COLORS
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} # this is in the grml config, but too early

in your zshrc for that.

Offline

#9 2023-09-09 15:15:12

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,483
Website

Re: [SOLVED]zshrc in Arch Install

seth wrote:

I assume he meant that as an example

An example of what?  The OP clarified they were not talking about `ls` output, but specifically tab completition for the cd command.  This should not contain any regular files.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#10 2023-09-09 15:40:22

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,661

Re: [SOLVED]zshrc in Arch Install

Example of autocompletion.

Offline

#11 2023-09-09 15:41:51

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,462

Re: [SOLVED]zshrc in Arch Install

I think he meant tab completion for "ls" command.
Anyway this has nothing to do with zsh or bash, OP can use

vivid generate <colorscheme>

and use it's output to set LS_COLORS in bash or zsh config file.

There are some screenshots to choose desired colorscheme at https://github.com/sharkdp/vivid

Offline

#12 2023-09-09 15:47:52

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,661

Re: [SOLVED]zshrc in Arch Install

You'll still have to make the shell use them (regardless of how you generate them, the iso/grml just uses the default dircolors)

Offline

#13 2023-09-09 18:44:24

robson75
Member
From: Poland
Registered: 2020-06-28
Posts: 144

Re: [SOLVED]zshrc in Arch Install

You can use the .zshrc file from the former anarchyinstaller, it also has nice colors.

#######################################################
####### Anarchy ZSH configuration file    #######
#######################################################

### Set/unset ZSH options
#########################
# setopt NOHUP
# setopt NOTIFY
# setopt NO_FLOW_CONTROL
setopt INC_APPEND_HISTORY SHARE_HISTORY
setopt APPEND_HISTORY
# setopt AUTO_LIST
# setopt AUTO_REMOVE_SLASH
# setopt AUTO_RESUME
unsetopt BG_NICE
setopt CORRECT
setopt EXTENDED_HISTORY
# setopt HASH_CMDS
setopt MENUCOMPLETE
setopt ALL_EXPORT

### Set/unset  shell options
############################
setopt   notify globdots correct pushdtohome cdablevars autolist
setopt   correctall autocd recexact longlistjobs
setopt   autoresume histignoredups pushdsilent
setopt   autopushd pushdminus extendedglob rcquotes mailwarning
unsetopt bgnice autoparamslash

### Autoload zsh modules when they are referenced
#################################################
autoload -U history-search-end
zmodload -a zsh/stat stat
zmodload -a zsh/zpty zpty
zmodload -a zsh/zprof zprof
#zmodload -ap zsh/mapfile mapfile
zle -N history-beginning-search-backward-end history-search-end
zle -N history-beginning-search-forward-end history-search-end

### Set variables
#################
PATH="/usr/local/bin:/usr/local/sbin/:$PATH"
HISTFILE=$HOME/.zhistory
HISTSIZE=1000
SAVEHIST=1000
LS_COLORS='rs=0:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:';

### Load colors
###############
autoload colors zsh/terminfo
if [[ "$terminfo[colors]" -ge 8 ]]; then
   colors
fi
for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
   eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
   eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
   (( count = $count + 1 ))
done

### Set Colors to use in in the script
#############
# Normal Colors
Black='\e[0;30m'        # Black
Red='\e[0;31m'          # Red
Green='\e[0;32m'        # Green
Yellow='\e[0;33m'       # Yellow
Blue='\e[0;34m'         # Blue
Purple='\e[0;35m'       # Purple
Cyan='\e[0;36m'         # Cyan
White='\e[0;37m'        # White

# Bold
BBlack='\e[1;30m'       # Black
BRed='\e[1;31m'         # Red
BGreen='\e[1;32m'       # Green
BYellow='\e[1;33m'      # Yellow
BBlue='\e[1;34m'        # Blue
BPurple='\e[1;35m'      # Purple
BCyan='\e[1;36m'        # Cyan
BWhite='\e[1;37m'       # White

# Background
On_Black='\e[40m'       # Black
On_Red='\e[41m'         # Red
On_Green='\e[42m'       # Green
On_Yellow='\e[43m'      # Yellow
On_Blue='\e[44m'        # Blue
On_Purple='\e[45m'      # Purple
On_Cyan='\e[46m'        # Cyan
On_White='\e[47m'       # White

NC="\e[m"               # Color Reset

### Set prompt
##############
PR_NO_COLOR="%{$terminfo[sgr0]%}"
PS1="[%(!.${PR_RED}%n.$PR_LIGHT_YELLOW%n)%(!.${PR_LIGHT_YELLOW}@.$PR_RED@)$PR_NO_COLOR%(!.${PR_LIGHT_RED}%U%m%u.${PR_LIGHT_GREEN}%U%m%u)$PR_NO_COLOR:%(!.${PR_RED}%2c.${PR_BLUE}%2c)$PR_NO_COLOR]%(?..[${PR_LIGHT_RED}%?$PR_NO_COLOR])%(!.${PR_LIGHT_RED}#.${PR_LIGHT_GREEN}$) "
RPS1="$PR_LIGHT_YELLOW(%D{%m-%d %H:%M})$PR_NO_COLOR"
unsetopt ALL_EXPORT

### set common functions
#############

function my_ip() # Get IP adress.
{
   curl ifconfig.co
}

# Find a file with a pattern in name:
function ff()
{
    find . -type f -iname '*'"$*"'*' -ls ;
}



function sysinfo()   # Get current host related info.
{
    echo -e "\n${BRed}System Informations:$NC " ; uname -a
    echo -e "\n${BRed}Online User:$NC " ; w -hs |
             cut -d " " -f1 | sort | uniq
    echo -e "\n${BRed}Date :$NC " ; date
    echo -e "\n${BRed}Server stats :$NC " ; uptime
    echo -e "\n${BRed}Memory stats :$NC " ; free
    echo -e "\n${BRed}Public IP Address :$NC " ; my_ip
    echo -e "\n${BRed}Open connections :$NC "; netstat -pan --inet;
    echo -e "\n${BRed}CPU info :$NC "; cat /proc/cpuinfo ;
    echo -e "\n"
}

function extract {
 if [ -z "$1" ]; then
    # display usage if no parameters given
    echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
 else
    if [ -f $1 ] ; then
        # NAME=${1%.*}
        # mkdir $NAME && cd $NAME
        case $1 in
          *.tar.bz2)   tar xvjf ../$1    ;;
          *.tar.gz)    tar xvzf ../$1    ;;
          *.tar.xz)    tar xvJf ../$1    ;;
          *.lzma)      unlzma ../$1      ;;
          *.bz2)       bunzip2 ../$1     ;;
          *.rar)       unrar x -ad ../$1 ;;
          *.gz)        gunzip ../$1      ;;
          *.tar)       tar xvf ../$1     ;;
          *.tbz2)      tar xvjf ../$1    ;;
          *.tgz)       tar xvzf ../$1    ;;
          *.zip)       unzip ../$1       ;;
          *.Z)         uncompress ../$1  ;;
          *.7z)        7z x ../$1        ;;
          *.xz)        unxz ../$1        ;;
          *.exe)       cabextract ../$1  ;;
          *)           echo "extract: '$1' - unknown archive method" ;;
        esac
    else
        echo "$1 - file does not exist"
    fi
fi
}


# Creates an archive (*.tar.gz) from given directory.
function maketar() { tar cvzf "${1%%/}.tar.gz"  "${1%%/}/"; }

# Create a ZIP archive of a file or folder.
function makezip() { zip -r "${1%%/}.zip" "$1" ; }


function my_ps() { ps $@ -u $USER -o pid,%cpu,%mem,bsdtime,command ; }

mcd () {
    mkdir -p $1
    cd $1
}

### Set alias
#############
alias cls="clear"
alias ..="cd .."
alias cd..="cd .."
alias ll="ls -lisa --color=auto"
alias home="cd ~"
alias df="df -ahiT --total"
alias mkdir="mkdir -pv"
alias mkfile="touch"
alias rm="rm -rfi"
alias userlist="cut -d: -f1 /etc/passwd"
alias ls="ls -CF --color=auto"
alias lsl="ls -lhFA | less"
alias free="free -mt"
alias du="du -ach | sort -h"
alias ps="ps auxf"
alias psgrep="ps aux | grep -v grep | grep -i -e VSZ -e"
alias wget="wget -c"
alias histg="history | grep"
alias myip="curl http://ipecho.net/plain; echo"
alias logs="find /var/log -type f -exec file {} \; | grep 'text' | cut -d' ' -f1 | sed -e's/:$//g' | grep -v '[0-9]$' | xargs tail -f"
alias folders='find . -maxdepth 1 -type d -print0 | xargs -0 du -sk | sort -rn'
alias grep='grep --color=auto'


### Bind keys
#############
autoload -U compinit
compinit
bindkey "^?" backward-delete-char
bindkey '^[OH' beginning-of-line
bindkey '^[OF' end-of-line
bindkey '^[[5~' up-line-or-history
bindkey '^[[6~' down-line-or-history
bindkey "^[[A" history-beginning-search-backward-end
bindkey "^[[B" history-beginning-search-forward-end
bindkey "^r" history-incremental-search-backward
bindkey ' ' magic-space    # also do history expansion on space
bindkey '^I' complete-word # complete on tab, leave expansion to _expand
zstyle ':completion::complete:*' use-cache on
zstyle ':completion::complete:*' cache-path ~/.zsh/cache/$HOST

zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' list-prompt '%SAt %p: Hit TAB for more, or the character to insert%s'
zstyle ':completion:*' menu select=1 _complete _ignored _approximate
zstyle -e ':completion:*:approximate:*' max-errors \
    'reply=( $(( ($#PREFIX+$#SUFFIX)/2 )) numeric )'
zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s'

# Completion Styles

# list of completers to use
zstyle ':completion:*::::' completer _expand _complete _ignored _approximate

# allow one error for every three characters typed in approximate completer
zstyle -e ':completion:*:approximate:*' max-errors \
    'reply=( $(( ($#PREFIX+$#SUFFIX)/2 )) numeric )'

# insert all expansions for expand completer
zstyle ':completion:*:expand:*' tag-order all-expansions

# formatting and messages
zstyle ':completion:*' verbose yes
zstyle ':completion:*:descriptions' format '%B%d%b'
zstyle ':completion:*:messages' format '%d'
zstyle ':completion:*:warnings' format 'No matches for: %d'
zstyle ':completion:*:corrections' format '%B%d (errors: %e)%b'
zstyle ':completion:*' group-name ''

# match uppercase from lowercase
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'

# offer indexes before parameters in subscripts
zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters

# command for process lists, the local web server details and host completion
# on processes completion complete all user processes
zstyle ':completion:*:processes' command 'ps -au$USER'

## add colors to processes for kill completion
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'

#zstyle ':completion:*:processes' command 'ps -o pid,s,nice,stime,args'
#zstyle ':completion:*:urls' local 'www' '/var/www/htdocs' 'public_html'
#
#NEW completion:
# 1. All /etc/hosts hostnames are in autocomplete
# 2. If you have a comment in /etc/hosts like #%foobar.domain,
#    then foobar.domain will show up in autocomplete!
zstyle ':completion:*' hosts $(awk '/^[^#]/ {print $2 $3" "$4" "$5}' /etc/hosts | grep -v ip6- && grep "^#%" /etc/hosts | awk -F% '{print $2}')
# Filename suffixes to ignore during completion (except after rm command)
zstyle ':completion:*:*:(^rm):*:*files' ignored-patterns '*?.o' '*?.c~' \
    '*?.old' '*?.pro'
# the same for old style completion
#fignore=(.o .c~ .old .pro)

# ignore completion functions (until the _ignored completer)
zstyle ':completion:*:functions' ignored-patterns '_*'
zstyle ':completion:*:*:*:users' ignored-patterns \
        adm apache bin daemon games gdm halt ident junkbust lp mail mailnull \
        named news nfsnobody nobody nscd ntp operator pcap postgres radvd \
        rpc rpcuser rpm shutdown squid sshd sync uucp vcsa xfs avahi-autoipd\
        avahi backup messagebus beagleindex debian-tor dhcp dnsmasq fetchmail\
        firebird gnats haldaemon hplip irc klog list man cupsys postfix\
        proxy syslog www-data mldonkey sys snort
# SSH Completion
zstyle ':completion:*:scp:*' tag-order \
   files users 'hosts:-host hosts:-domain:domain hosts:-ipaddr"IP\ Address *'
zstyle ':completion:*:scp:*' group-order \
   files all-files users hosts-domain hosts-host hosts-ipaddr
zstyle ':completion:*:ssh:*' tag-order \
   users 'hosts:-host hosts:-domain:domain hosts:-ipaddr"IP\ Address *'
zstyle ':completion:*:ssh:*' group-order \
   hosts-domain hosts-host users hosts-ipaddr
zstyle '*' single-ignored show

### Source plugins
##################
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

Arch Linux Xfce - 64Bit Linux User #621110

Offline

#14 2023-09-09 21:55:50

cloverskull
Member
Registered: 2018-09-30
Posts: 277

Re: [SOLVED]zshrc in Arch Install

It might seem like you're trying to go the simplest route - get just the parts of a zshrc that you want for a color scheme - but I think in the end you may actually be making things more difficult. My suggestion would be to implement oh-my-zsh and find a theme you like, then introduce some addons from https://github.com/zsh-users/

Offline

#15 2023-09-09 23:41:21

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,483
Website

Re: [SOLVED]zshrc in Arch Install

cloverskull wrote:

It might seem like you're trying to go the simplest route - get just the parts of a zshrc that you want for a color scheme - but I think in the end you may actually be making things more difficult.

While I already disagreed here, this difference could be claimed to be a matter of taste.  Inheriting large complex configs that one doesn't understand is a bad idea.  One can look at other (well made) configs and learn how to implement their own.

cloverskull wrote:

My suggestion would be to implement oh-my-zsh

You then went and pulled out the nuclear hand-grenade option.  That is not only not a good suggestion, it is extremely harmful.  Actively encouraging new users to use OMZ should be a bannable offense.

Last edited by Trilby (2023-09-09 23:43:00)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#16 2023-09-10 06:13:16

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,661

Re: [SOLVED]zshrc in Arch Install

Yes "should" …

@cloverskull, please understand that your position would represent an extreme minority in this environment.

My suggested approach for the OP - once they actually manage the installation wink - would be to install https://archlinux.org/packages/extra/an … sh-config/ to have a somewhat nice config right now.
Then start looking at it and tweak it into their own preferences (at which point it has to be removed from the local package database or put on the ignore list to not get the changes destroyed)
Reading the (vast!) zsh manuals to make up a fancy shell config out of the void is tedious and probably frustrating.

OMZ is however an almost surefire way to turn your zsh into a disfunctional mess, doing so merely for a colorscheme is batshit crazy.

Offline

#17 2023-09-10 10:05:01

b42
Member
Registered: 2023-07-20
Posts: 203

Re: [SOLVED]zshrc in Arch Install

Fixed it - all I was looking for was this one single line:

zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"

Offline

#18 2023-09-10 16:45:20

b42
Member
Registered: 2023-07-20
Posts: 203

Re: [SOLVED]zshrc in Arch Install

How do I get colored output from commands in the terminal like this?

Jy0r1XFNoTrz.jpg

Offline

#19 2023-09-10 18:33:12

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,661

Re: [SOLVED]zshrc in Arch Install

https://wiki.archlinux.org/title/Color_ … console#ip - you mabe want to read the entire wiki page?

Offline

#20 2023-09-10 20:50:42

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,661

Re: [SOLVED]zshrc in Arch Install

@cloverskull
https://www.google.com/search?q=OMZ%20% … hlinux.org

At the core of this is probably just its bloat and complexity - one plugin doesn't know what the others do and  the execution order can matter.
It has consistently and so often shown up at the bottom of "my zsh is totally broken" threads that at some point the forum consensus became that OMZ is uncontrollable FUBAR.
On top of that, most users seem to install it because of powerline, what's nonse. You can have powerline regardless.

You're of course absolutely entitled to use it, just
1. you've been warned tongue
2. advertising it here will get you some form of opposition wink

Offline

#21 2023-09-10 21:21:24

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,483
Website

Re: [SOLVED]zshrc in Arch Install

More damning are the countless other threads where the problem wasn't even zsh related nor was anything about zsh or OMZ even in the thread title, but yet after dozens of agonizing posts into the thread we find that OMZ managed to break yet another part of the operating system which is really shouldn't even be possible for a shell config to affect.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#22 2023-09-11 00:03:35

cloverskull
Member
Registered: 2018-09-30
Posts: 277

Re: [SOLVED]zshrc in Arch Install

@seth @Trilby thanks for the explanation smile I had no idea, my bad.

Offline

Board footer

Powered by FluxBB