From b1402c0372164139b3790ab49c4c858dba3659d4 Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 16 May 2016 21:35:29 +1000 Subject: [PATCH 01/33] Foundations for terminal font support --- neofetch | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 1c7048f3..4eba3793 100755 --- a/neofetch +++ b/neofetch @@ -56,7 +56,8 @@ printinfo () { info "WM Theme" wmtheme info "Theme" theme info "Icons" icons - info "Font" font + info "Terminal Emulator" term + info "Terminal Font" termfont info "CPU" cpu info "GPU" gpu info "Memory" memory @@ -1734,6 +1735,38 @@ getfont () { # }}} +# Terminal Emulator {{{ + +getterm () { + parent="$(ps -p ${1:-$PPID} -o ppid=)" + name="$(ps -p $parent -o comm=)" + + case "$name" in + "${SHELL/*\/}" | *"sh") getterm "$parent" ;; + *) term="$name" ;; + esac +} + +# }}} + +# Terminal Emulator Font {{{ + +gettermfont () { + [ -z "$term" ] && getterm + + case "$term" in + "urxvt"*) + # Need to figure out how to best parse the Xresources file. + ;; + + "xfce4-terminal") + termfont="$(awk -F '=' '/FontName/ {printf $2}' "${XDG_CONFIG_HOME}/xfce4/terminal/terminalrc")" + ;; + esac +} + +# }}} + # Disk Usage {{{ getdisk () { From 8032f6ca7ad6c94c67ddf064f92ea27dcc37cb29 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 16 May 2016 21:52:22 +1000 Subject: [PATCH 02/33] termfont: Add termite support --- neofetch | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/neofetch b/neofetch index 4eba3793..76a9735d 100755 --- a/neofetch +++ b/neofetch @@ -1762,6 +1762,10 @@ gettermfont () { "xfce4-terminal") termfont="$(awk -F '=' '/FontName/ {printf $2}' "${XDG_CONFIG_HOME}/xfce4/terminal/terminalrc")" ;; + + "termite") + termfont="$(awk -F '= ' '/font/ {printf $2; exit}' "${XDG_CONFIG_HOME}/termite/config")" + ;; esac } From e223b034ef4cf69f4540f7c3ce5c7ee8f1f6de84 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 16 May 2016 22:29:08 +1000 Subject: [PATCH 03/33] Find ppid of tmux --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 76a9735d..cd920066 100755 --- a/neofetch +++ b/neofetch @@ -1742,7 +1742,7 @@ getterm () { name="$(ps -p $parent -o comm=)" case "$name" in - "${SHELL/*\/}" | *"sh") getterm "$parent" ;; + "${SHELL/*\/}" | *"sh" | "tmux") getterm "$parent" ;; *) term="$name" ;; esac } From 6a96072efe5017b02edb2510ef4f9bbcee887cbf Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 16 May 2016 22:41:40 +1000 Subject: [PATCH 04/33] iTerm2 detection --- neofetch | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/neofetch b/neofetch index cd920066..e75db2db 100755 --- a/neofetch +++ b/neofetch @@ -1738,13 +1738,18 @@ getfont () { # Terminal Emulator {{{ getterm () { - parent="$(ps -p ${1:-$PPID} -o ppid=)" - name="$(ps -p $parent -o comm=)" + [ -n "$ITERM_PROFILE" ] && term="iTerm2" - case "$name" in - "${SHELL/*\/}" | *"sh" | "tmux") getterm "$parent" ;; - *) term="$name" ;; - esac + # Check $PPID for terminal emulator. + if [ -z "$term" ]; then + parent="$(ps -p ${1:-$PPID} -o ppid=)" + name="$(ps -p $parent -o comm=)" + + case "$name" in + "${SHELL/*\/}" | *"sh" | "tmux") getterm "$parent" ;; + *) term="$name" ;; + esac + fi } # }}} From d8214dd0cd5c5faaa6e922dfd56fe66237566746 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 17 May 2016 00:07:22 +1000 Subject: [PATCH 05/33] termfont: Terminator support --- neofetch | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/neofetch b/neofetch index 76a9735d..ca875894 100755 --- a/neofetch +++ b/neofetch @@ -1766,6 +1766,13 @@ gettermfont () { "termite") termfont="$(awk -F '= ' '/font/ {printf $2; exit}' "${XDG_CONFIG_HOME}/termite/config")" ;; + + "terminator") + # This only works on a global basis right now. + # We need to figure out a way to get the current + # profile in use. + termfont="$(awk -F '= ' '/font/ {printf $2; exit}' "${XDG_CONFIG_HOME}/terminator/config")" + ;; esac } From abb110b57f8c0fe898d90c9aa8727df7e1b8a8d1 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 17 May 2016 00:30:11 +1000 Subject: [PATCH 06/33] termfont: Add URxvt support, Ignore commented lines in config files --- neofetch | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/neofetch b/neofetch index be347e84..a6039e17 100755 --- a/neofetch +++ b/neofetch @@ -1746,7 +1746,7 @@ getterm () { name="$(ps -p $parent -o comm=)" case "$name" in - "${SHELL/*\/}" | *"sh" | "tmux") getterm "$parent" ;; + "${SHELL/*\/}" | *"sh" | "tmux" | "systemd") getterm "$parent" ;; *) term="$name" ;; esac fi @@ -1761,22 +1761,33 @@ gettermfont () { case "$term" in "urxvt"*) - # Need to figure out how to best parse the Xresources file. + termfont="$(awk -F ': ' '!/^($|!)/ && /\*font/ {printf $2}' "$HOME/.Xresources")" + + case "$termfont" in + "xft:"*) + termfont=${termfont/xft:} + termfont=${termfont/:*} + ;; + + "-"*) + termfont="$(awk -F '\\-' '{printf $3}' <<< "$termfont")" + ;; + esac ;; "xfce4-terminal") - termfont="$(awk -F '=' '/FontName/ {printf $2}' "${XDG_CONFIG_HOME}/xfce4/terminal/terminalrc")" + termfont="$(awk -F '=' '!/^($|\/\/)/ && /FontName/ {printf $2}' "${XDG_CONFIG_HOME}/xfce4/terminal/terminalrc")" ;; "termite") - termfont="$(awk -F '= ' '/font/ {printf $2; exit}' "${XDG_CONFIG_HOME}/termite/config")" + termfont="$(awk -F '= ' '!/^($|#)/ && /font/ {printf $2; exit}' "${XDG_CONFIG_HOME}/termite/config")" ;; "terminator") # This only works on a global basis right now. # We need to figure out a way to get the current # profile in use. - termfont="$(awk -F '= ' '/font/ {printf $2; exit}' "${XDG_CONFIG_HOME}/terminator/config")" + termfont="$(awk -F '= ' '!/^($|#)/ && /font/ {printf $2; exit}' "${XDG_CONFIG_HOME}/terminator/config")" ;; esac } From 54380788888e37b78f9014d667f7b549ea1c9d93 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 17 May 2016 00:38:07 +1000 Subject: [PATCH 07/33] termfont: xterm support --- neofetch | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/neofetch b/neofetch index a6039e17..c7ef1daf 100755 --- a/neofetch +++ b/neofetch @@ -1760,18 +1760,22 @@ gettermfont () { [ -z "$term" ] && getterm case "$term" in - "urxvt"*) - termfont="$(awk -F ': ' '!/^($|!)/ && /\*font/ {printf $2}' "$HOME/.Xresources")" + "urxvt"* | "xterm") + # Check for a different font line if the term is urxvt or xterm. + case "$term" in + "urxvt"*) termfont="$(awk -F ': ' '!/^($|!)/ && /t\*font/ {printf $2}' "$HOME/.Xresources")" ;; + "xterm") termfont="$(awk -F ': ' '!/^($|!)/ && /m\*font/ {printf $2}' "$HOME/.Xresources")" ;; + esac + # Xresources has two different font syntax, this checks which + # one is in use and formats it accordingly. case "$termfont" in "xft:"*) termfont=${termfont/xft:} termfont=${termfont/:*} ;; - "-"*) - termfont="$(awk -F '\\-' '{printf $3}' <<< "$termfont")" - ;; + "-"*) termfont="$(awk -F '\\-' '{printf $3}' <<< "$termfont")" ;; esac ;; From bbbc7aca045a0c92205fdf41027ecd67afdc81b3 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 17 May 2016 06:54:57 +1000 Subject: [PATCH 08/33] Do a case insensitive grep instead of duplicating awk commands --- neofetch | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/neofetch b/neofetch index c7ef1daf..238b2cb4 100755 --- a/neofetch +++ b/neofetch @@ -1760,12 +1760,9 @@ gettermfont () { [ -z "$term" ] && getterm case "$term" in - "urxvt"* | "xterm") - # Check for a different font line if the term is urxvt or xterm. - case "$term" in - "urxvt"*) termfont="$(awk -F ': ' '!/^($|!)/ && /t\*font/ {printf $2}' "$HOME/.Xresources")" ;; - "xterm") termfont="$(awk -F ': ' '!/^($|!)/ && /m\*font/ {printf $2}' "$HOME/.Xresources")" ;; - esac + "urxvt" | "urxvtd" | "xterm") + termfont="$(grep -i "${term/d}\*font" "$HOME/.Xresources")" + termfont=${termfont/*font: } # Xresources has two different font syntax, this checks which # one is in use and formats it accordingly. From 31dbdaa85a7ad161e0f0fd070785f2804ee4f45b Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 17 May 2016 17:20:19 +1000 Subject: [PATCH 09/33] Add support for OS X terminals --- neofetch | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 238b2cb4..48f35a7c 100755 --- a/neofetch +++ b/neofetch @@ -1738,7 +1738,13 @@ getfont () { # Terminal Emulator {{{ getterm () { - [ -n "$ITERM_PROFILE" ] && term="iTerm2" + # Workaround for OS X systems that + # don't support the block below. + case "$TERM_PROGRAM" in + "iTerm.app") term="iTerm2" ;; + "Terminal.app") term="Apple Terminal" ;; + *) term="${TERM_PROGRAM/\.app}" ;; + esac # Check $PPID for terminal emulator. if [ -z "$term" ]; then From 1fa9324ca9aea3aec7b7fa7ede97106341ab80c9 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 17 May 2016 18:53:47 +1000 Subject: [PATCH 10/33] termfont: iTerm2 support --- neofetch | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/neofetch b/neofetch index 48f35a7c..c283004f 100755 --- a/neofetch +++ b/neofetch @@ -1790,12 +1790,17 @@ gettermfont () { termfont="$(awk -F '= ' '!/^($|#)/ && /font/ {printf $2; exit}' "${XDG_CONFIG_HOME}/termite/config")" ;; + # This only works on a global basis right now. + # We need to figure out a way to get the current + # profile in use. "terminator") - # This only works on a global basis right now. - # We need to figure out a way to get the current - # profile in use. termfont="$(awk -F '= ' '!/^($|#)/ && /font/ {printf $2; exit}' "${XDG_CONFIG_HOME}/terminator/config")" ;; + + "iTerm2") + termfile="$(/usr/libexec/plistbuddy -c Print ~/Library/Preferences/com.googlecode.iterm2.plist)" + termfont="$(awk -F '= ' '/Normal Font/ {printf $2; exit}' <<< "$termfile")" + ;; esac } From 7ed11db606827beefcdc5de7e42f1826db3afe29 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 17 May 2016 20:46:32 +1000 Subject: [PATCH 11/33] termfont: iTerm2 profile aware font --- neofetch | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/neofetch b/neofetch index c283004f..7427abca 100755 --- a/neofetch +++ b/neofetch @@ -1799,7 +1799,8 @@ gettermfont () { "iTerm2") termfile="$(/usr/libexec/plistbuddy -c Print ~/Library/Preferences/com.googlecode.iterm2.plist)" - termfont="$(awk -F '= ' '/Normal Font/ {printf $2; exit}' <<< "$termfile")" + termfont="$(awk -v pattern="Name = $ITERM_PROFILE" -F '= ' '$0 ~ pattern {printf $2 " "} /Normal Font/ {printf $2 " "}' <<< "$termfile")" + termfont=${termfont/ $ITERM_PROFILE*} ;; esac } From 3f2d51ae5af394b3bda6666dce8661223d494175 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 17 May 2016 21:12:38 +1000 Subject: [PATCH 12/33] revert iterm2 profile parsing --- neofetch | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/neofetch b/neofetch index 7427abca..c283004f 100755 --- a/neofetch +++ b/neofetch @@ -1799,8 +1799,7 @@ gettermfont () { "iTerm2") termfile="$(/usr/libexec/plistbuddy -c Print ~/Library/Preferences/com.googlecode.iterm2.plist)" - termfont="$(awk -v pattern="Name = $ITERM_PROFILE" -F '= ' '$0 ~ pattern {printf $2 " "} /Normal Font/ {printf $2 " "}' <<< "$termfile")" - termfont=${termfont/ $ITERM_PROFILE*} + termfont="$(awk -F '= ' '/Normal Font/ {printf $2; exit}' <<< "$termfile")" ;; esac } From d17eee816ee229be8beca2d094ea585a908dc101 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 18 May 2016 14:20:49 +1000 Subject: [PATCH 13/33] Remove global parsing --- neofetch | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/neofetch b/neofetch index c283004f..e0a3ba0c 100755 --- a/neofetch +++ b/neofetch @@ -1789,18 +1789,6 @@ gettermfont () { "termite") termfont="$(awk -F '= ' '!/^($|#)/ && /font/ {printf $2; exit}' "${XDG_CONFIG_HOME}/termite/config")" ;; - - # This only works on a global basis right now. - # We need to figure out a way to get the current - # profile in use. - "terminator") - termfont="$(awk -F '= ' '!/^($|#)/ && /font/ {printf $2; exit}' "${XDG_CONFIG_HOME}/terminator/config")" - ;; - - "iTerm2") - termfile="$(/usr/libexec/plistbuddy -c Print ~/Library/Preferences/com.googlecode.iterm2.plist)" - termfont="$(awk -F '= ' '/Normal Font/ {printf $2; exit}' <<< "$termfile")" - ;; esac } From d4adbecf9e93bc6a2a0c3cbe9ff0358cf9a49c1f Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 18 May 2016 15:22:50 +1000 Subject: [PATCH 14/33] Terminal detection, add screen support: --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index e0a3ba0c..844f35bd 100755 --- a/neofetch +++ b/neofetch @@ -1752,7 +1752,7 @@ getterm () { name="$(ps -p $parent -o comm=)" case "$name" in - "${SHELL/*\/}" | *"sh" | "tmux" | "systemd") getterm "$parent" ;; + "${SHELL/*\/}" | *"sh" | "tmux" | "screen" | "systemd") getterm "$parent" ;; *) term="$name" ;; esac fi From 8b9a3ce90ec93a9e3175c0adf416b619baf48a4d Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 18 May 2016 15:27:34 +1000 Subject: [PATCH 15/33] Enable Terminal and Terminal font by default --- config/config | 6 ++++-- neofetch | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/config/config b/config/config index 5f77e057..a19db9c5 100644 --- a/config/config +++ b/config/config @@ -29,18 +29,20 @@ printinfo () { info "WM Theme" wmtheme info "Theme" theme info "Icons" icons - info "Font" font + info "Terminal Emulator" term + info "Terminal Font" termfont info "CPU" cpu info "GPU" gpu info "Memory" memory # info "Disk" disk # info "Battery" battery + # info "Font" font + # info "Song" song # info "Local IP" localip # info "Public IP" publicip # info "Users" users # info "Birthday" birthday - # info "Song" song info linebreak info cols diff --git a/neofetch b/neofetch index 844f35bd..39bc0b1f 100755 --- a/neofetch +++ b/neofetch @@ -64,6 +64,7 @@ printinfo () { # info "Disk" disk # info "Battery" battery + # info "Font" font # info "Song" song # info "Local IP" localip # info "Public IP" publicip From f8e6dd980b05b003472ef9e648e57afc4381c097 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 18 May 2016 15:51:25 +1000 Subject: [PATCH 16/33] CYGWIN and it's not standard ps... --- neofetch | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/neofetch b/neofetch index 39bc0b1f..5f00800b 100755 --- a/neofetch +++ b/neofetch @@ -1749,8 +1749,21 @@ getterm () { # Check $PPID for terminal emulator. if [ -z "$term" ]; then - parent="$(ps -p ${1:-$PPID} -o ppid=)" - name="$(ps -p $parent -o comm=)" + case "$os" in + "Windows") + parent="$(ps -p ${1:-$PPID} | awk '{printf $2}')" + parent=${parent/'PPID'} + + name="$(ps -p $parent | awk '{printf $8}')" + name=${name/'COMMAND'} + name=${name/*\/} + ;; + + *) + parent="$(ps -p ${1:-$PPID} -o ppid=)" + name="$(ps -p $parent -o comm=)" + ;; + esac case "$name" in "${SHELL/*\/}" | *"sh" | "tmux" | "screen" | "systemd") getterm "$parent" ;; From 8d87b786c28c22b810d24b0453511121de101555 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 18 May 2016 16:39:05 +1000 Subject: [PATCH 17/33] termfont: mintty support --- neofetch | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/neofetch b/neofetch index 5f00800b..bdac6c4e 100755 --- a/neofetch +++ b/neofetch @@ -1803,6 +1803,10 @@ gettermfont () { "termite") termfont="$(awk -F '= ' '!/^($|#)/ && /font/ {printf $2; exit}' "${XDG_CONFIG_HOME}/termite/config")" ;; + + "mintty") + termfont="$(awk -F '=' '!/^($|#)/ && /Font/ {printf $2; exit}' "${HOME}/.minttyrc")" + ;; esac } From 9d63edcbf7c9d2fef744b11e8644a451824ff010 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 18 May 2016 17:05:32 +1000 Subject: [PATCH 18/33] Fix bug with ascii size, the pure bash solution counted the file a little weirdly causing issues for some ascii art --- ascii/distro/windows | 2 +- neofetch | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/ascii/distro/windows b/ascii/distro/windows index 4dd86003..1aac3ab8 100644 --- a/ascii/distro/windows +++ b/ascii/distro/windows @@ -3,7 +3,7 @@ ${c1} ,.=:!!t3Z3z., :tt:::tt333EE3 ${c1} Et:::ztt33EEEL${c2} @Ee., .., ${c1} ;tt:::tt333EE7${c2} ;EEEEEEttttt33# -${c1} :Et:::zt333EEQ.${c2} \$EEEEEttttt33QL +${c1} :Et:::zt333EEQ.${c2} $EEEEEttttt33QL ${c1} it::::tt333EEF${c2} @EEEEEEttttt33F ${c1} ;3=*^\`\`\`\"*4EEV${c2} :EEEEEEttttt33@. ${c3} ,.=::::!t=., ${c1}\`${c2} @EEEEEEtttz33QF diff --git a/neofetch b/neofetch index bdac6c4e..058e940b 100755 --- a/neofetch +++ b/neofetch @@ -2204,16 +2204,13 @@ getascii () { # Turn the file into a variable and strip escape codes. ascii_strip=$(<"$ascii") ascii_strip=${ascii_strip//\$\{??\}} - ascii_strip=${ascii_strip//\\\\/ } - ascii_strip=${ascii_strip//\\} + ascii_strip=${ascii_strip//'\\'} + ascii_strip=${ascii_strip//'\'} # Get length of longest line - # Get lines/columns of the ascii file in pure bash. - while read -r line 2>/dev/null; do - [ ${#line} -gt ${ascii_length:-0} ] && ascii_length=${#line} - lines=$((lines+=1)) - done <<< "$ascii_strip" - lines=$((lines+=1)) + ascii_size="$(awk 'END {printf NR " "}length>max{max=length}END{printf max}' <<< "$ascii_strip")" + lines=${ascii_size/ *} + ascii_length=${ascii_size/$lines} padding="\033[$((ascii_length + gap))C" printf "%b%s" "$print" From d5049680412ae4d8f3fc77b859a9b7d5acd358f7 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 21 May 2016 00:33:48 +1000 Subject: [PATCH 19/33] termfont: Parse xrdb instead of .XresourceS --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 058e940b..9faa2395 100755 --- a/neofetch +++ b/neofetch @@ -1781,7 +1781,7 @@ gettermfont () { case "$term" in "urxvt" | "urxvtd" | "xterm") - termfont="$(grep -i "${term/d}\*font" "$HOME/.Xresources")" + termfont="$(grep -i "${term/d}\*font" <<< $(xrdb -query))" termfont=${termfont/*font: } # Xresources has two different font syntax, this checks which From 184149c30214266b35d1eb85851d961271f09bed Mon Sep 17 00:00:00 2001 From: Andrew Titmuss Date: Mon, 23 May 2016 12:35:47 +1000 Subject: [PATCH 20/33] added apple terminal font support --- neofetch | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/neofetch b/neofetch index 9faa2395..9cefba0e 100755 --- a/neofetch +++ b/neofetch @@ -1807,6 +1807,10 @@ gettermfont () { "mintty") termfont="$(awk -F '=' '!/^($|#)/ && /Font/ {printf $2; exit}' "${HOME}/.minttyrc")" ;; + + "Apple_Terminal") + termfont="$(osascript -e 'tell application "Terminal" to font name of window frontmost')" + ;; esac } From 91b66052f18296db03f19f94b9676c58c8010dff Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 28 May 2016 10:14:45 +1000 Subject: [PATCH 21/33] Remove needless split between blocks --- neofetch | 56 +++++++++++++++++++++++++++----------------------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/neofetch b/neofetch index 9faa2395..0407c63d 100755 --- a/neofetch +++ b/neofetch @@ -1739,37 +1739,35 @@ getfont () { # Terminal Emulator {{{ getterm () { - # Workaround for OS X systems that - # don't support the block below. - case "$TERM_PROGRAM" in - "iTerm.app") term="iTerm2" ;; - "Terminal.app") term="Apple Terminal" ;; - *) term="${TERM_PROGRAM/\.app}" ;; + # Check $PPID for terminal emulator. + case "$os" in + "Darwin") + case "$TERM_PROGRAM" in + "iTerm.app") term="iTerm2" ;; + "Terminal.app") term="Apple Terminal" ;; + *) term="${TERM_PROGRAM/\.app}" ;; + esac + ;; + + "Windows") + parent="$(ps -p ${1:-$PPID} | awk '{printf $2}')" + parent=${parent/'PPID'} + + name="$(ps -p $parent | awk '{printf $8}')" + name=${name/'COMMAND'} + name=${name/*\/} + ;; + + *) + parent="$(ps -p ${1:-$PPID} -o ppid=)" + name="$(ps -p $parent -o comm=)" + ;; esac - # Check $PPID for terminal emulator. - if [ -z "$term" ]; then - case "$os" in - "Windows") - parent="$(ps -p ${1:-$PPID} | awk '{printf $2}')" - parent=${parent/'PPID'} - - name="$(ps -p $parent | awk '{printf $8}')" - name=${name/'COMMAND'} - name=${name/*\/} - ;; - - *) - parent="$(ps -p ${1:-$PPID} -o ppid=)" - name="$(ps -p $parent -o comm=)" - ;; - esac - - case "$name" in - "${SHELL/*\/}" | *"sh" | "tmux" | "screen" | "systemd") getterm "$parent" ;; - *) term="$name" ;; - esac - fi + case "$name" in + "${SHELL/*\/}" | *"sh" | "tmux" | "screen" | "systemd") getterm "$parent" ;; + *) term="$name" ;; + esac } # }}} From 8d33b4051f0d13c1153311b882031af36728872b Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 28 May 2016 10:24:35 +1000 Subject: [PATCH 22/33] Fix incorrect OS value --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 59a653cf..9053a61e 100755 --- a/neofetch +++ b/neofetch @@ -1741,7 +1741,7 @@ getfont () { getterm () { # Check $PPID for terminal emulator. case "$os" in - "Darwin") + "Mac OS X") case "$TERM_PROGRAM" in "iTerm.app") term="iTerm2" ;; "Terminal.app") term="Apple Terminal" ;; From ec1705835c18e0d42fefe96df285678c8da52970 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 28 May 2016 10:27:58 +1000 Subject: [PATCH 23/33] Revert last two commits --- neofetch | 52 +++++++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/neofetch b/neofetch index 9053a61e..9cefba0e 100755 --- a/neofetch +++ b/neofetch @@ -1739,35 +1739,37 @@ getfont () { # Terminal Emulator {{{ getterm () { + # Workaround for OS X systems that + # don't support the block below. + case "$TERM_PROGRAM" in + "iTerm.app") term="iTerm2" ;; + "Terminal.app") term="Apple Terminal" ;; + *) term="${TERM_PROGRAM/\.app}" ;; + esac + # Check $PPID for terminal emulator. - case "$os" in - "Mac OS X") - case "$TERM_PROGRAM" in - "iTerm.app") term="iTerm2" ;; - "Terminal.app") term="Apple Terminal" ;; - *) term="${TERM_PROGRAM/\.app}" ;; - esac - ;; + if [ -z "$term" ]; then + case "$os" in + "Windows") + parent="$(ps -p ${1:-$PPID} | awk '{printf $2}')" + parent=${parent/'PPID'} - "Windows") - parent="$(ps -p ${1:-$PPID} | awk '{printf $2}')" - parent=${parent/'PPID'} + name="$(ps -p $parent | awk '{printf $8}')" + name=${name/'COMMAND'} + name=${name/*\/} + ;; - name="$(ps -p $parent | awk '{printf $8}')" - name=${name/'COMMAND'} - name=${name/*\/} - ;; + *) + parent="$(ps -p ${1:-$PPID} -o ppid=)" + name="$(ps -p $parent -o comm=)" + ;; + esac - *) - parent="$(ps -p ${1:-$PPID} -o ppid=)" - name="$(ps -p $parent -o comm=)" - ;; - esac - - case "$name" in - "${SHELL/*\/}" | *"sh" | "tmux" | "screen" | "systemd") getterm "$parent" ;; - *) term="$name" ;; - esac + case "$name" in + "${SHELL/*\/}" | *"sh" | "tmux" | "screen" | "systemd") getterm "$parent" ;; + *) term="$name" ;; + esac + fi } # }}} From fd30321120bea7d0b174f598c48898ac2b31a8ea Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 28 May 2016 11:05:29 +1000 Subject: [PATCH 24/33] Update ascii changes --- neofetch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/neofetch b/neofetch index 9cefba0e..ad87859c 100755 --- a/neofetch +++ b/neofetch @@ -2208,10 +2208,10 @@ getascii () { # Turn the file into a variable and strip escape codes. ascii_strip=$(<"$ascii") ascii_strip=${ascii_strip//\$\{??\}} - ascii_strip=${ascii_strip//'\\'} + ascii_strip=${ascii_strip//'\\'/ } ascii_strip=${ascii_strip//'\'} - # Get length of longest line + # Get ascii file size in rows/cols ascii_size="$(awk 'END {printf NR " "}length>max{max=length}END{printf max}' <<< "$ascii_strip")" lines=${ascii_size/ *} ascii_length=${ascii_size/$lines} From 5a99cb5237cf819669ed015378fccae884537274 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 28 May 2016 11:16:13 +1000 Subject: [PATCH 25/33] term: Add support for tty --- neofetch | 1 + 1 file changed, 1 insertion(+) diff --git a/neofetch b/neofetch index ad87859c..6eaa8bf5 100755 --- a/neofetch +++ b/neofetch @@ -1767,6 +1767,7 @@ getterm () { case "$name" in "${SHELL/*\/}" | *"sh" | "tmux" | "screen" | "systemd") getterm "$parent" ;; + "login" | "init") term="$(tty)"; term=${term/*\/} ;; *) term="$name" ;; esac fi From f2eb877bae53e4eb15706a31102ad06c512560e8 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 28 May 2016 11:19:24 +1000 Subject: [PATCH 26/33] Remove all whitespace from terminal name --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 6eaa8bf5..c248072e 100755 --- a/neofetch +++ b/neofetch @@ -1765,7 +1765,7 @@ getterm () { ;; esac - case "$name" in + case "${name// }" in "${SHELL/*\/}" | *"sh" | "tmux" | "screen" | "systemd") getterm "$parent" ;; "login" | "init") term="$(tty)"; term=${term/*\/} ;; *) term="$name" ;; From 79f8d55a568f364826d1c7cc4f556deade4f69a1 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 28 May 2016 11:22:34 +1000 Subject: [PATCH 27/33] Shorten terminal title --- config/config | 2 +- neofetch | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config b/config/config index a19db9c5..9afbc8e4 100644 --- a/config/config +++ b/config/config @@ -29,7 +29,7 @@ printinfo () { info "WM Theme" wmtheme info "Theme" theme info "Icons" icons - info "Terminal Emulator" term + info "Terminal" term info "Terminal Font" termfont info "CPU" cpu info "GPU" gpu diff --git a/neofetch b/neofetch index c248072e..32f006e5 100755 --- a/neofetch +++ b/neofetch @@ -56,7 +56,7 @@ printinfo () { info "WM Theme" wmtheme info "Theme" theme info "Icons" icons - info "Terminal Emulator" term + info "Terminal" term info "Terminal Font" termfont info "CPU" cpu info "GPU" gpu From 64d268027812fd8c500479b11942bd098aead5ad Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 28 May 2016 11:28:41 +1000 Subject: [PATCH 28/33] Add term and termfont to --test --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 32f006e5..5c1f1e9c 100755 --- a/neofetch +++ b/neofetch @@ -3183,7 +3183,7 @@ while [ "$1" ]; do esac ;; --test) - info=(title underline distro kernel uptime packages shell resolution de wm wmtheme theme icons cpu gpu memory font disk battery song localip publicip users birthday) + info=(title underline distro kernel uptime packages shell resolution de wm wmtheme theme icons cpu gpu memory font disk battery song localip publicip users birthday term termfont) refresh_rate="on" shell_version="on" From a8460768073abe676956e68ee9ffd65dcdf2c8e3 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 28 May 2016 11:31:15 +1000 Subject: [PATCH 29/33] Fix some travis issues --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 5c1f1e9c..2292199d 100755 --- a/neofetch +++ b/neofetch @@ -1766,7 +1766,7 @@ getterm () { esac case "${name// }" in - "${SHELL/*\/}" | *"sh" | "tmux" | "screen" | "systemd") getterm "$parent" ;; + "${SHELL/*\/}" | *"sh" | "tmux" | "screen" | "systemd" | "sshd" | "ruby") getterm "$parent" ;; "login" | "init") term="$(tty)"; term=${term/*\/} ;; *) term="$name" ;; esac From a7f7218b24042cb0b19165bda3f6b3e8e1d89719 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 28 May 2016 11:35:20 +1000 Subject: [PATCH 30/33] More Travis fixes --- neofetch | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 2292199d..0efd9a89 100755 --- a/neofetch +++ b/neofetch @@ -1766,8 +1766,9 @@ getterm () { esac case "${name// }" in - "${SHELL/*\/}" | *"sh" | "tmux" | "screen" | "systemd" | "sshd" | "ruby") getterm "$parent" ;; + "${SHELL/*\/}" | *"sh" | "tmux" | "screen") getterm "$parent" ;; "login" | "init") term="$(tty)"; term=${term/*\/} ;; + "ruby" | "1" | "systemd" | "sshd") unset term ;; *) term="$name" ;; esac fi From 37e7d8e4b3b410f0973eee9503039aca257c1a8f Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 28 May 2016 11:38:41 +1000 Subject: [PATCH 31/33] Condense term function --- neofetch | 63 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/neofetch b/neofetch index 0efd9a89..f008c50e 100755 --- a/neofetch +++ b/neofetch @@ -1739,39 +1739,40 @@ getfont () { # Terminal Emulator {{{ getterm () { - # Workaround for OS X systems that - # don't support the block below. - case "$TERM_PROGRAM" in - "iTerm.app") term="iTerm2" ;; - "Terminal.app") term="Apple Terminal" ;; - *) term="${TERM_PROGRAM/\.app}" ;; + # Check $PPID for terminal emulator. + case "$os" in + "Mac OS X") + # Workaround for OS X systems that + # don't support the block below. + case "$TERM_PROGRAM" in + "iTerm.app") term="iTerm2" ;; + "Terminal.app") term="Apple Terminal" ;; + *) term="${TERM_PROGRAM/\.app}" ;; + esac + return + ;; + + "Windows") + parent="$(ps -p ${1:-$PPID} | awk '{printf $2}')" + parent=${parent/'PPID'} + + name="$(ps -p $parent | awk '{printf $8}')" + name=${name/'COMMAND'} + name=${name/*\/} + ;; + + *) + parent="$(ps -p ${1:-$PPID} -o ppid=)" + name="$(ps -p $parent -o comm=)" + ;; esac - # Check $PPID for terminal emulator. - if [ -z "$term" ]; then - case "$os" in - "Windows") - parent="$(ps -p ${1:-$PPID} | awk '{printf $2}')" - parent=${parent/'PPID'} - - name="$(ps -p $parent | awk '{printf $8}')" - name=${name/'COMMAND'} - name=${name/*\/} - ;; - - *) - parent="$(ps -p ${1:-$PPID} -o ppid=)" - name="$(ps -p $parent -o comm=)" - ;; - esac - - case "${name// }" in - "${SHELL/*\/}" | *"sh" | "tmux" | "screen") getterm "$parent" ;; - "login" | "init") term="$(tty)"; term=${term/*\/} ;; - "ruby" | "1" | "systemd" | "sshd") unset term ;; - *) term="$name" ;; - esac - fi + case "${name// }" in + "${SHELL/*\/}" | *"sh" | "tmux" | "screen") getterm "$parent" ;; + "login" | "init") term="$(tty)"; term=${term/*\/} ;; + "ruby" | "1" | "systemd" | "sshd") unset term ;; + *) term="$name" ;; + esac } # }}} From c1450f828898ed92eba4ca416a1a637052b4101f Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 2 Jun 2016 21:14:19 +1000 Subject: [PATCH 32/33] Fix trailing '-' with gnome-terminal --- neofetch | 1 + 1 file changed, 1 insertion(+) diff --git a/neofetch b/neofetch index f008c50e..00ff1ca5 100755 --- a/neofetch +++ b/neofetch @@ -1771,6 +1771,7 @@ getterm () { "${SHELL/*\/}" | *"sh" | "tmux" | "screen") getterm "$parent" ;; "login" | "init") term="$(tty)"; term=${term/*\/} ;; "ruby" | "1" | "systemd" | "sshd") unset term ;; + "gnome-terminal-") term="gnome-terminal" ;; *) term="$name" ;; esac } From c5b88c68a9d9a6ca6af4ebeb557ad771da420bf1 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 3 Jun 2016 18:08:19 +1000 Subject: [PATCH 33/33] If the parent process is python, exit the function --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 00ff1ca5..7642237c 100755 --- a/neofetch +++ b/neofetch @@ -1770,7 +1770,7 @@ getterm () { case "${name// }" in "${SHELL/*\/}" | *"sh" | "tmux" | "screen") getterm "$parent" ;; "login" | "init") term="$(tty)"; term=${term/*\/} ;; - "ruby" | "1" | "systemd" | "sshd") unset term ;; + "ruby" | "1" | "systemd" | "sshd" | "python"*) unset term ;; "gnome-terminal-") term="gnome-terminal" ;; *) term="$name" ;; esac