Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
neofetch
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ximper Linux
neofetch
Commits
43239ecd
Commit
43239ecd
authored
Feb 19, 2016
by
Dylan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fallback to ascii mode instead of hanging if the terminal emulator doesn't…
Fallback to ascii mode instead of hanging if the terminal emulator doesn't support xterm escape sequences
parent
6bb05edf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
19 deletions
+20
-19
config
config/config
+2
-2
fetch
fetch
+18
-17
No files found.
config/config
View file @
43239ecd
...
@@ -262,8 +262,8 @@ crop_offset="center"
...
@@ -262,8 +262,8 @@ crop_offset="center"
# Image size
# Image size
# The image is half the terminal width by default.
# The image is half the terminal width by default.
# --size
half
, px
# --size
auto
, px
image_size
=
"
half
"
image_size
=
"
auto
"
# Right gap between image and text
# Right gap between image and text
# --gap num
# --gap num
...
...
fetch
View file @
43239ecd
...
@@ -280,8 +280,8 @@ crop_offset="center"
...
@@ -280,8 +280,8 @@ crop_offset="center"
# Image size
# Image size
# The image is half the terminal width by default.
# The image is half the terminal width by default.
# --size
half
, px
# --size
auto
, px
image_size
=
"
half
"
image_size
=
"
auto
"
# Right gap between image and text
# Right gap between image and text
# --gap num
# --gap num
...
@@ -1851,24 +1851,11 @@ getimage () {
...
@@ -1851,24 +1851,11 @@ getimage () {
;;
;;
esac
esac
# If
$img
isn't a file, fallback to ascii mode.
if [ ! -f "
$img
" ]; then
# Fallback to ascii mode
image="
ascii
"
getascii
return
fi
# Get terminal lines and columns
columns=
$(
tput cols
)
lines=
$(
tput lines
)
# Get terminal width and height
# Get terminal width and height
printf "
%b%s
" '
\0
33[14t'
printf "
%b%s
" '
\0
33[14t'
index=0
index=0
while IFS= read -s -r -n 1 char; do
while IFS= read -s -r -n 1
-t 0.25
char; do
case "
$index
" in
case "
$index
" in
"
0
") [ "
$char
" == "
;
" ] && index=
$((
index
+
1
))
;;
"
0
") [ "
$char
" == "
;
" ] && index=
$((
index
+
1
))
;;
"
1
") [ "
$char
" == "
;
" ] && index=
$((
index
+
1
))
|| term_height="
${
term_height
}${
char
}
" ;;
"
1
") [ "
$char
" == "
;
" ] && index=
$((
index
+
1
))
|| term_height="
${
term_height
}${
char
}
" ;;
...
@@ -1876,12 +1863,26 @@ getimage () {
...
@@ -1876,12 +1863,26 @@ getimage () {
esac
esac
done
done
# If
$img
isn't a file or the terminal doesn't support xterm escape sequences,
# fallback to ascii mode.
if [ ! -f "
$img
" ] || [ -z "
$term_height
" ]; then
# Fallback to ascii mode
image="
ascii
"
getascii
return
fi
# Get terminal lines and columns
columns=
$(
tput cols
)
lines=
$(
tput lines
)
# Calculate font size
# Calculate font size
font_width=
$((
term_width
/
columns
))
font_width=
$((
term_width
/
columns
))
font_height=
$((
term_height
/
lines
))
font_height=
$((
term_height
/
lines
))
# Image size is half of the terminal
# Image size is half of the terminal
if [ "
$image_size
" == "
half
" ]; then
if [ "
$image_size
" == "
auto
" ]; then
image_size=
$((
columns
*
font_width
/
2
))
image_size=
$((
columns
*
font_width
/
2
))
[ "
$((
term_height
-
term_height
/
4
))
" -lt "
$image_size
" ] &&
\
[ "
$((
term_height
-
term_height
/
4
))
" -lt "
$image_size
" ] &&
\
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment