aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xpfetch48
1 files changed, 32 insertions, 16 deletions
diff --git a/pfetch b/pfetch
index e311bc8..5206ae8 100755
--- a/pfetch
+++ b/pfetch
@@ -112,8 +112,9 @@ log() {
# End here if no data was found.
[ "$2" ] || return
- # Store the value of '$1' as we reset the argument list below.
+ # Store the values of '$1' and '$3' as we reset the argument list below.
name=$1
+ use_seperator=$3
# Use 'set --' as a means of stripping all leading and trailing
# white-space from the info string. This also normalizes all
@@ -138,8 +139,8 @@ log() {
printf '%s' "$name"
esc_p SGR 0
- # Print the info name and info data separator.
- printf %s "$PF_SEP"
+ # Print the info name and info data separator, if applicable.
+ [ "$use_seperator" ] || printf %s "$PF_SEP"
# Move the cursor backward the length of the *current* info name and
# then move it forwards the length of the *longest* info name. This
@@ -189,7 +190,7 @@ get_title() {
esc SGR "3${PF_COL3:-1}"
hostname=$e$hostname
- log "${user}@${hostname}" " " >&6
+ log "${user}@${hostname}" " " " " >&6
}
get_os() {
@@ -1070,7 +1071,9 @@ get_shell() {
get_editor() {
# Display the value of '$VISUAL', if it's empty, display the
# value of '$EDITOR'.
- log editor "${VISUAL:-$EDITOR}" >&6
+ editor=${VISUAL:-"$EDITOR"}
+
+ log editor "${editor##*/}" >&6
}
get_palette() {
@@ -1090,10 +1093,10 @@ get_palette() {
palette="$palette$e"
}
- # Print the palette with a new-line before and afterwards.
+ # Print the palette with a new-line before and afterwards but no seperator.
printf '\n' >&6
log "$palette
- " " " >&6
+ " " " " " >&6
}
get_ascii() {
@@ -1785,16 +1788,29 @@ get_ascii() {
}
main() {
- [ "$1" = --version ] && {
- printf 'pfetch 0.7.0\n'
- exit 0
- }
+ case $* in
+ -v)
+ printf '%s 0.7.0\n' "${0##*/}"
+ return 0
+ ;;
- # Hide 'stderr' unless the first argument is '-v'. This saves
- # polluting the script with '2>/dev/null'.
- [ "$1" = -v ] || {
- exec 2>/dev/null
- }
+ -d)
+ # Below exec is not run, stderr is shown.
+ ;;
+
+ '')
+ exec 2>/dev/null
+ ;;
+
+ *)
+ cat <<EOF
+${0##*/} show system information
+${0##*/} -d show stderr (debug mode)
+${0##*/} -v show version information
+EOF
+ return 0
+ ;;
+ esac
# Hide 'stdout' and selectively print to it using '>&6'.
# This gives full control over what it displayed on the screen.