Unverified Commit 1b67413d authored by Dylan Araps's avatar Dylan Araps Committed by GitHub

Merge pull request #1153 from dylanaraps/ascii_enhance

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