image: Added kitty backend. Closes #953

This commit is contained in:
Dylan Araps 2018-04-20 07:48:41 +10:00
parent 38e929967f
commit 2606e4b1d6
2 changed files with 12 additions and 27 deletions

View File

@ -2629,7 +2629,7 @@ image_backend() {
"off") image_backend="off" ;; "off") image_backend="off" ;;
"caca" | "catimg" | "jp2a" | "iterm2" | "termpix" |\ "caca" | "catimg" | "jp2a" | "iterm2" | "termpix" |\
"tycat" | "w3m" | "sixel" | "pixterm") "tycat" | "w3m" | "sixel" | "pixterm" | "kitty")
get_image_source get_image_source
if [[ ! -f "$image" ]]; then if [[ ! -f "$image" ]]; then
@ -2654,7 +2654,7 @@ image_backend() {
*) *)
err "Image: Unknown image backend specified '$image_backend'." err "Image: Unknown image backend specified '$image_backend'."
err "Image: Valid backends are: 'ascii', 'caca', 'catimg', 'jp2a', 'iterm2', err "Image: Valid backends are: 'ascii', 'caca', 'catimg', 'jp2a', 'iterm2', 'kitty',
'off', 'sixel', 'pixterm', 'termpix', 'tycat', 'w3m')" 'off', 'sixel', 'pixterm', 'termpix', 'tycat', 'w3m')"
err "Image: Falling back to ascii mode." err "Image: Falling back to ascii mode."
get_ascii get_ascii
@ -3066,6 +3066,11 @@ display_image() {
to_off "Image: jp2a failed to display the image." to_off "Image: jp2a failed to display the image."
;; ;;
"kitty")
kitty icat --align left --place "${width}x${height}@${xoffset}x${yoffset}" "$image" ||\
to_off "Image: kitty failed to display the image."
;;
"pixterm") "pixterm")
pixterm -tc "$((width / font_width))" \ pixterm -tc "$((width / font_width))" \
-tr "$((height / font_height))" \ -tr "$((height / font_height))" \
@ -4762,6 +4767,7 @@ IMAGE BACKEND:
--catimg source Shortcut to use 'catimg' backend. --catimg source Shortcut to use 'catimg' 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.
--kitty source Shortcut to use 'kitty' backend.
--pixterm source Shortcut to use 'pixterm' backend. --pixterm source Shortcut to use 'pixterm' backend.
--sixel source Shortcut to use 'sixel' backend. --sixel source Shortcut to use 'sixel' backend.
--termpix source Shortcut to use 'termpix' backend. --termpix source Shortcut to use 'termpix' backend.
@ -4949,7 +4955,7 @@ get_args() {
"--backend") image_backend="$2" ;; "--backend") image_backend="$2" ;;
"--source") image_source="$2" ;; "--source") image_source="$2" ;;
"--ascii" | "--caca" | "--catimg" | "--jp2a" | "--iterm2" | "--off" | "--pixterm" |\ "--ascii" | "--caca" | "--catimg" | "--jp2a" | "--iterm2" | "--off" | "--pixterm" |\
"--sixel" | "--termpix" | "--tycat" | "--w3m") "--sixel" | "--termpix" | "--tycat" | "--w3m" | "--kitty")
image_backend="${1/--}" image_backend="${1/--}"
case "$2" in case "$2" in
"-"* | "") ;; "-"* | "") ;;

View File

@ -211,6 +211,9 @@ Shortcut to use 'iterm2' backend.
\fB\-\-jp2a\fR source \fB\-\-jp2a\fR source
Shortcut to use 'jp2a' backend. Shortcut to use 'jp2a' backend.
.TP .TP
\fB\-\-kitty\fR source
Shortcut to use 'kitty' backend.
.TP
\fB\-\-pixterm\fR source \fB\-\-pixterm\fR source
Shortcut to use 'pixterm' backend. Shortcut to use 'pixterm' backend.
.TP .TP
@ -338,29 +341,5 @@ Display a verbose log for error reporting.
.TP .TP
\fB\-\-gen\-man\fR \fB\-\-gen\-man\fR
Generate a manpage for Neofetch in your PWD. (Requires GNU help2man) Generate a manpage for Neofetch in your PWD. (Requires GNU help2man)
.SH AUTHOR
Written by Dylan Araps with help from the following people:
.PP
https://github.com/dylanaraps/neofetch/contributors
.SH "REPORTING BUGS" .SH "REPORTING BUGS"
Report bugs to https://github.com/dylanaraps/neofetch/issues Report bugs to https://github.com/dylanaraps/neofetch/issues
.SH COPYRIGHT
Copyright \(co 2016\-2017 Dylan Araps
.PP
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the 'Software'), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
.PP
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
.PP
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.