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
e05cf162
Commit
e05cf162
authored
Jan 18, 2017
by
Dylan Araps
Committed by
GitHub
Jan 18, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #623 from dylanaraps/full_path
General: Neofetch now understands relative paths
parents
3b29a9b7
7d20f75e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
19 deletions
+35
-19
neofetch
neofetch
+35
-19
No files found.
neofetch
View file @
e05cf162
...
...
@@ -2013,8 +2013,8 @@ get_ascii() {
ascii_dir="
/data/data/com.termux/files/usr/share/neofetch/ascii/distro
"
else
get_script_dir 2>/dev/null
ascii_dir="
${
script_dir
}
/ascii/distro
"
[[ -z "
$script_dir
" ]] && script_dir="
$(
get_full_path
"
$0
"
)
"
ascii_dir="
${
script_dir
%/*
}
/ascii/distro
"
fi
image_source="
${
ascii_dir
}
/
${
ascii_file
}
"
...
...
@@ -2056,11 +2056,14 @@ get_ascii() {
get_image_source() {
case "
$image_source
" in
"
auto
" | "
wall
"*
)
"
auto
" | "
wall
paper
"
)
get_wallpaper 2>/dev/null
;;
*)
# Get the absolute path.
image_source="
$(
get_full_path
"
$image_source
"
)
"
if [[ -d "
$image_source
" ]]; then
shopt -s nullglob
files=("
${
image_source
%/
}
"/*.{png,jpg,jpeg,jpe,gif})
...
...
@@ -3247,22 +3250,32 @@ err() {
err+="$(color 1)[!]\033[0m $1\n"
}
get_script_dir() {
[[ "$script_dir" ]] && return
get_full_path() {
# This function finds the absolute path from a relative one.
# For example "Pictures/Wallpapers" --> "/home/dylan/Pictures/Wallpapers"
# If the file exists in the current directory, stop here.
[[ -f "${PWD}/${1%/*}" ]] && { printf "%s\n" "${PWD}/${1%/*}"; return; }
if ! cd "${1%/*}"; then
err "Error: Directory '
${
1
%/*
}
' doesn'
t
exist or is inaccessible
"
err "
Check that the directory exists or try another directory.
"
exit 1
fi
# Use $0 to get the script'
s
physical path.
cd
"
${
0
%/*
}
"
|| exit
script_dir=
"
${
0
##*/
}
"
local full_dir="
${
1
##*/
}
"
# Iterate down a (possible) chain of symlinks.
while [[ -L
"
$
script
_dir
"
]]; do
script_dir=
"
$(
readlink
"
$script
_dir
"
)
"
cd
"
${
script
_dir
%/*
}
"
|| exit
script_dir=
"
${
script
_dir
##*/
}
"
while [[ -L "
$
full
_dir
" ]]; do
full_dir="
$(
readlink
"
$full
_dir
"
)
"
cd "
${
full
_dir
%/*
}
" || exit
full_dir="
${
full
_dir
##*/
}
"
done
# Final directory.
script_dir=
"
$(
pwd
-P
)
"
full_dir="
$(
pwd
-P
)
/
${
1
/*\/
}
"
[[ -e "
$full_dir
" ]] && printf "
%s\n
" "
$full_dir
"
}
get_default_config() {
...
...
@@ -3273,9 +3286,9 @@ get_default_config() {
default_config="
/data/data/com.termux/files/etc/neofetch/config
"
else
get_script_dir
default_config=
"
${
script_dir
}
/config/config"
travis_config=
"
${
script_dir
}
/config/travis"
[[ -z "
$script_dir
" ]] && script_dir="
$(
get_full_path
"
$0
"
)
"
default_config="
${
script_dir
%/*
}
/config/config
"
travis_config="
${
script_dir
%/*
}
/config/travis
"
fi
if source "
$default_config
"; then
...
...
@@ -3315,9 +3328,9 @@ get_user_config() {
config_file="
${
XDG_CONFIG_HOME
}
/neofetch/config
"
else
get_script_dir
[[ -z "
$script_dir
" ]] && script_dir="
$(
get_full_path
"
$0
"
)
"
cp
"
${
script_dir
}
/config/config"
"
${
XDG_CONFIG_HOME
}
/neofetch"
cp "
${
script_dir
%/*
}
/config/config
" "
${
XDG_CONFIG_HOME
}
/neofetch
"
config_file="
${
XDG_CONFIG_HOME
}
/neofetch/config
"
fi
...
...
@@ -3984,7 +3997,10 @@ get_args() {
"--config"
)
case
"
$2
"
in
"none"
|
"off"
|
""
)
;;
*
)
config_file
=
"
$2
"
;
get_user_config 2>/dev/null
;;
*
)
config_file
=
"
$(
get_full_path
"
$2
"
)
"
get_user_config 2>/dev/null
;;
esac
;;
"-v"
)
verbose
=
"on"
;;
...
...
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