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
254e92d0
Commit
254e92d0
authored
Dec 15, 2016
by
Dylan Araps
Committed by
GitHub
Dec 15, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #530 from dylanaraps/prin
General: Delete most of info() and instead call prin()
parents
e2626d00
6c5b5576
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
45 deletions
+24
-45
neofetch
neofetch
+24
-45
No files found.
neofetch
View file @
254e92d0
...
@@ -273,7 +273,10 @@ get_model() {
...
@@ -273,7 +273,10 @@ get_model() {
}
}
get_title
()
{
get_title
()
{
title
=
"
${
USER
:-$(
whoami
||
printf
"%s"
"
${
HOME
/*\/
}
"
)}
@
${
HOSTNAME
:-$(
hostname
)}
"
user
=
"
${
USER
:-$(
whoami
||
printf
"%s"
"
${
HOME
/*\/
}
"
)}
"
hostname
=
"
${
HOSTNAME
:-$(
hostname
)}
"
title
=
"
${
title_color
}${
bold
}${
user
}${
at_color
}
@
${
title_color
}${
bold
}${
hostname
}
"
length
=
"
$((${#
user
}
+
${#
hostname
}
+
1
))
"
}
}
get_kernel
()
{
get_kernel
()
{
...
@@ -1266,7 +1269,6 @@ get_song() {
...
@@ -1266,7 +1269,6 @@ get_song() {
else
else
prin
"
$subtitle
"
"
$song
"
prin
"
$subtitle
"
"
$song
"
fi
fi
unset
song
fi
fi
}
}
...
@@ -1676,8 +1678,6 @@ get_battery() {
...
@@ -1676,8 +1678,6 @@ get_battery() {
prin "
${
subtitle
}${
bat
:
-1
}
" "
$battery
"
prin "
${
subtitle
}${
bat
:
-1
}
" "
$battery
"
done
done
unset battery
return
return
;;
;;
...
@@ -2425,77 +2425,56 @@ scrot_program() {
...
@@ -2425,77 +2425,56 @@ scrot_program() {
# TEXT FORMATTING
# TEXT FORMATTING
info() {
info() {
#
$1
is the subtitle
#
Make sure that
$prin
is unset.
subtitle="
$1
"
unset -v prin
# Call the function.
# Call the function.
"
get_
${
2
:-
$1
}
" 2>/dev/null
"
get_
${
2
:-
$1
}
" 2>/dev/null
# Update the variable
# If the get_func function called 'prin' directly, stop here.
output="
${
2
:-
$1
}
"
[[ "
$prin
" ]] && return
output="
$(
trim
"
${
!output
}
"
)
"
# If prin was used in the function, stop here.
[[ "
$prin
" ]] &&
\
unset prin && return
# If the output is empty, don't print anything.
[[ -z "
${
output
//
}
" ]] &&
\
err "
Info
:
Couldn
't detect $subtitle." && return
case "$1" in
"title")
string="${title_color}${bold}${output}"
string="${string/@/${at_color}@${title_color}${bold}}"
length="${#output}"
;;
"underline") string="${underline_color}${output}" ;;
# Update the variable
output="
$(
trim
"
${
!2
:-${
!1
}}
"
)
"
*)
if [[ "
$2
" && "
${
output
//
}
" ]]; then
string="${subtitle_color}${bold}${subtitle}${reset}"
length="
$((${#
1
}
+
${#
output
}
+
2
))
"
string+="${colon_color}: ${info_color}${output}"
prin "
$1
" "
$output
"
length="$((${#subtitle} + ${#output} + 2))"
;;
esac
# If there'
s
no subtitle don
't print one
elif [[ "
${
output
//
}
" ]]; then
[[ -z "$2" ]] && string="${string/*: }"
[[ -z "
$length
" ]] && length="
${#
output
}
"
prin "
$output
"
# Print the string
else
printf "%b\n" "\033[${text_padding}C${zws}${string}${reset} "
err "
Info
:
Couldn
't detect ${1}."
fi
# Calculate info height
info_height="$((info_height+=1))"
}
}
prin() {
prin() {
string="${1//$'
\033[0m
'}${2:+: $2}"
# If $2 doesn'
t
exist we format
$1
as info
# If $2 doesn'
t
exist we format
$1
as info
[[ -z
"
$2
"
]] && local subtitle_color=
"
$info_color
"
[[ -z
"
$2
"
]] && local subtitle_color=
"
$info_color
"
# Format the output
# Format the output
string=
"
${
1
//
$'
\0
33[0m'
}${
2
:+:
$2
}
"
string=
"
$(
trim
"
$string
"
)
"
string=
"
${
string
/
:/
${
reset
}${
colon_color
}
:
${
info_color
}}
"
string=
"
${
string
/
:/
${
reset
}${
colon_color
}
:
${
info_color
}}
"
string=
"
${
subtitle_color
}${
bold
}${
string
}
"
string=
"
${
subtitle_color
}${
bold
}${
string
}
"
# Trim whitespace
string=
"
$(
trim
"
$string
"
)
"
# Print the info
# Print the info
printf
"%b
\n
"
"
\0
33[
${
text_padding
}
C
${
zws
}${
string
}${
reset
}
"
printf
"%b
\n
"
"
\0
33[
${
text_padding
}
C
${
zws
}${
string
}${
reset
}
"
# Calculate info height
# Calculate info height
info_height=
"
$((
info_height+
=
1
))
"
info_height=
"
$((
info_height+
=
1
))
"
#
Tell info() that prin()
was used.
#
Log that prin
was used.
prin=1
prin=1
}
}
get_underline() {
get_underline() {
if [[ "
$underline_enabled
" == "
on
" ]]; then
if [[ "
$underline_enabled
" == "
on
" ]]; then
underline="
$(
printf
%
"
$length
"
s
)
"
underline="
$(
printf
%
"
$length
"
s
)
"
underline="
${
underline
// /
$underline_char
}
"
underline="
${
underline_color
}${
underline
// /
$underline_char
}
"
unset -v length
fi
fi
}
}
...
...
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