Получение разрешения нескольких изображений при в то же время

Поведение быстрого расширения Zsh определено в man zshmisc. Что касается установки пользовательских значений длины подсказки, в нем говорится:

   %<string<
   %>string>
   %[xstring]
      Specifies  truncation  behaviour for the remainder of the prompt
      string.   The  third,  deprecated,   form   is   equivalent   to
      `%xstringx',  i.e. x may be `<' or `>'.  The string will be dis‐
      played in place of the truncated portion  of  any  string;  note
      this does not undergo prompt expansion.

      The numeric argument, which in the third form may appear immedi‐
      ately after the `[', specifies the maximum permitted  length  of
      the various strings that can be displayed in the prompt.  In the
      first two forms, this numeric argument may be negative, in which
      case  the  truncation  length  is  determined by subtracting the
      absolute value of the numeric argument from the number of  char‐
      acter  positions  remaining on the current prompt line.  If this
      results in a zero or negative length, a length of 1 is used.  In
      other  words, a negative argument arranges that after truncation
      at least n characters remain before the right margin (left  mar‐
      gin for RPROMPT).

      The  forms  with `<' truncate at the left of the string, and the
      forms with `>' truncate at the right of the string.   For  exam‐
      ple,  if  the  current  directory  is  `/home/pike',  the prompt
      `%8<..<%/' will expand to `..e/pike'.  In this string, the  ter‐
      minating  character (`<', `>' or `]'), or in fact any character,
      may be quoted by a preceding `\'; note when using print -P, how‐
      ever, that this must be doubled as the string is also subject to
      standard  print  processing,  in  addition  to  any  backslashes
      removed  by a double quoted string:  the worst case is therefore
      `print -P "%<\\\\<<..."'.

      If the string is longer than the specified truncation length, it
      will appear in full, completely replacing the truncated string.

      The part of the prompt string to be truncated runs to the end of
      the string, or to the end of the next  enclosing  group  of  the
      `%('  construct,  or  to  the next truncation encountered at the
      same grouping level (i.e. truncations inside a  `%('  are  sepa‐
      rate), which ever comes first.  In particular, a truncation with
      argument zero (e.g., `%<<') marks the end of the  range  of  the
      string  to  be truncated while turning off truncation from there
      on. For example, the prompt  `%10<...<%~%<<%#  '  will  print  a
      truncated representation of the current directory, followed by a
      `%' or `#', followed by a space.  Without the `%<<',  those  two
      characters  would  be  included  in  the string to be truncated.
      Note that `%-0<<' is not equivalent to `%<<' but specifies  that
      the prompt is truncated at the right margin.

      Truncation  applies  only  within  each  individual  line of the
      prompt, as delimited by embedded  newlines  (if  any).   If  the
      total  length  of  any  line  of  the prompt after truncation is
      greater than the terminal width, or if the part to be  truncated
      contains embedded newlines, truncation behavior is undefined and
      may  change  in  a   future   version   of   the   shell.    Use
      `%-n(l.true-text.false-text)' to remove parts of the prompt when
      the available space is less than n.

Из этого вы можете сделать вывод

  • PROMPT="%/ " предоставит вам рабочий каталог
  • PROMPT='%10<..<%/ ' даст вам рабочий каталог - если строка рабочего каталога длиннее 10 символов, она будет усечена по левому краю, а там, где происходит усечение, будет отображаться шаблон .. ( для указания усеченного значения)

Ширина терминала может быть получена с помощью $COLUMNS, поэтому, если вы хотите, чтобы приглашение ограничивалось 25% ширины терминала, замените 10 переменной :

width=$(($COLUMNS / 4))

т.е.

PROMPT="%${width}<..<%/ %% "
0
18.07.2017, 16:41
2 ответа

Использование ImageMagick identifyдля получения разрешения всех файлов JPG в текущем каталоге:

for image in *.jpg *.jpeg *.png
do
   echo "$image :"
   identify -format "%[fx:w]x%[fx:h]\n" "$image"
done
3
28.01.2020, 02:19

Вы можете использовать exiftoolдля получения метаданных изображений.

Чтобы установить инструмент в Debian/Ubuntu:

sudo apt-get install libimage-exiftool-perl

В Arch Linux:

sudo pacman -Sy perl-image-exiftool

Где -Sдля синхронизации пакетов (пакеты устанавливаются непосредственно из удаленных репозиториев, включая все необходимые зависимости )и -yдля загрузки свежей копии базы данных основных пакетов с сервера (s )определено вpacman.conf(5)(изman pacman).

Затем для извлечения необходимых данных:

for image in./images/*
do
   exiftool "-*FileName*" "-*ImageSize*" "$image"
done

Вывод будет:

File Name                       : linux.jpg
Image Size                      : 1920x1080
File Name                       : background.jpg
Image Size                      : 1020x980
1
28.01.2020, 02:19

Теги

Похожие вопросы