Merge pull request #1153 from dylanaraps/ascii_enhance
ascii: Added support for command output
This commit is contained in:
commit
1b67413d49
26
neofetch
26
neofetch
|
@ -660,6 +660,7 @@ image_backend="ascii"
|
|||
#
|
||||
# Default: 'auto'
|
||||
# Values: 'auto', 'ascii', 'wallpaper', '/path/to/img', '/path/to/ascii', '/path/to/dir/'
|
||||
# 'command output (neofetch --ascii "$(fortune | cowsay -W 30)")'
|
||||
# Flag: --source
|
||||
#
|
||||
# NOTE: 'auto' will pick the best image source for whatever image backend is used.
|
||||
|
@ -3416,20 +3417,24 @@ image_backend() {
|
|||
}
|
||||
|
||||
get_ascii() {
|
||||
if [[ -f "$image_source" && ! "$image_source" =~ (png|jpg|jpeg|jpe|svg|gif) ]]; then
|
||||
ascii_data="$(< "$image_source")"
|
||||
else
|
||||
err "Ascii: Ascii file not found, using distro ascii."
|
||||
fi
|
||||
[[ ! "$image_source" =~ (ascii|auto) ]] &&
|
||||
if [[ -f "$image_source" && ! "$image_source" =~ (png|jpg|jpeg|jpe|svg|gif) ]]; then
|
||||
ascii_data="$(< "$image_source")"
|
||||
else
|
||||
ascii_data="$image_source"
|
||||
fi
|
||||
|
||||
# Set locale to get correct padding.
|
||||
LC_ALL="$sys_locale"
|
||||
|
||||
# Calculate size of ascii file in line length / line count.
|
||||
while IFS=$'\n' read -r line; do
|
||||
((++lines,${#line}>ascii_length)) && ascii_length="${#line}"
|
||||
((++lines,${#line}>ascii_len)) && ascii_len="${#line}"
|
||||
done <<< "${ascii_data//\$\{??\}}"
|
||||
|
||||
# Fallback if file not found.
|
||||
((lines==1)) && { lines=; ascii_len=; image_source="auto"; get_distro_ascii; get_ascii; return; }
|
||||
|
||||
# Colors.
|
||||
ascii_data="${ascii_data//\$\{c1\}/$c1}"
|
||||
ascii_data="${ascii_data//\$\{c2\}/$c2}"
|
||||
|
@ -3438,7 +3443,7 @@ get_ascii() {
|
|||
ascii_data="${ascii_data//\$\{c5\}/$c5}"
|
||||
ascii_data="${ascii_data//\$\{c6\}/$c6}"
|
||||
|
||||
((text_padding=ascii_length+gap))
|
||||
((text_padding=ascii_len+gap))
|
||||
printf '%b\n' "$ascii_data${reset}"
|
||||
LC_ALL=C
|
||||
}
|
||||
|
@ -4371,8 +4376,12 @@ IMAGE BACKEND:
|
|||
'sixel', 'tycat', 'w3m'
|
||||
--source source Which image or ascii file to use.
|
||||
Possible values: 'auto', 'ascii', 'wallpaper', '/path/to/img',
|
||||
'/path/to/ascii', '/path/to/dir/'
|
||||
'/path/to/ascii', '/path/to/dir/', 'command output' [ascii]
|
||||
|
||||
--ascii source Shortcut to use 'ascii' backend.
|
||||
|
||||
NEW: neofetch --ascii \"\$(fortune | cowsay -W 30)\"
|
||||
|
||||
--caca source Shortcut to use 'caca' backend.
|
||||
--iterm2 source Shortcut to use 'iterm2' backend.
|
||||
--jp2a source Shortcut to use 'jp2a' backend.
|
||||
|
@ -4595,7 +4604,6 @@ get_args() {
|
|||
"--ascii_distro")
|
||||
image_backend="ascii"
|
||||
ascii_distro="$2"
|
||||
case "$2" in "-"* | "") ascii_distro="$distro" ;; esac
|
||||
;;
|
||||
|
||||
"--ascii_bold") ascii_bold="$2" ;;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.7.
|
||||
.TH NEOFETCH "1" "October 2018" "Neofetch 5.0.1" "User Commands"
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.8.
|
||||
.TH NEOFETCH "1" "January 2019" "Neofetch 5.0.1" "User Commands"
|
||||
.SH NAME
|
||||
Neofetch \- A fast, highly customizable system info script
|
||||
.SH SYNOPSIS
|
||||
|
@ -199,10 +199,12 @@ Possible values: 'ascii', 'caca', 'jp2a', 'iterm2', 'off',
|
|||
\fB\-\-source\fR source
|
||||
Which image or ascii file to use.
|
||||
Possible values: 'auto', 'ascii', 'wallpaper', '/path/to/img',
|
||||
\&'/path/to/ascii', '/path/to/dir/'
|
||||
\&'/path/to/ascii', '/path/to/dir/', 'command output' [ascii]
|
||||
.TP
|
||||
\fB\-\-ascii\fR source
|
||||
Shortcut to use 'ascii' backend.
|
||||
.IP
|
||||
NEW: neofetch \fB\-\-ascii\fR "$(fortune | cowsay \fB\-W\fR 30)"
|
||||
.TP
|
||||
\fB\-\-caca\fR source
|
||||
Shortcut to use 'caca' backend.
|
||||
|
|
Reference in New Issue