3

The Prezto documentation has the following example script for setting up symlinks:

setopt EXTENDED_GLOB
for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do
  ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"
done

I understand everything in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N) up until (.N). What does (.N) mean here?

Bonus question, what is ${rcfile:t}? I understand that it resolves to the name of the rcfile but I don't know what the :t is for.

knpwrs
  • 15,691
  • 12
  • 62
  • 103

2 Answers2

4

The bellow piece denies or negates (.N) all content wich starts '^' with README.md ^README.md(.N)

The ^ symbol is a regular expression the means the beginning of something.

The ${rcfile:t} part allows only the name stripping the dir name of string. Therefore the loop will create a needed symlink for each configuration file of your zpresto dir.

AdrieanKhisbe
  • 3,899
  • 8
  • 37
  • 45
SergioAraujo
  • 11,069
  • 3
  • 50
  • 40
2

The glob (extended glob, actually) ^README.md(.N) expands to all files except README.md, or returns null (an empty string).

extended: Set by the setopt line. Needed for the ^ (see below).

files: The dot in (.N) stands for files (not directories nor links).

except README.md: The ^. Think of ^ inside brackets in a regex. That does not mean files beginning with README.md.

null: The N in (.N). It says the globbing to return a null string if the expansion fails. Otherwise that line would return an error if ${ZDOTDIR:-$HOME}"/.zprezto/runcoms/" had only the README.md file or no files at all.

Montalvao
  • 31
  • 2