[PR] dylanaraps/neofetch#2271 from m-ildefons - feat: display editor setting

Upstream PR: https://github.com/dylanaraps/neofetch/pull/2271
Thanks to @m-ildefons

Co-authored-by: Moritz Röhrich <moritz@ildefons.de>
This commit is contained in:
Azalea 2022-12-28 21:35:53 -05:00
commit 51ed5be11e
2 changed files with 69 additions and 0 deletions

View file

@ -62,6 +62,7 @@ print_info() {
info "Uptime" uptime info "Uptime" uptime
info "Packages" packages info "Packages" packages
info "Shell" shell info "Shell" shell
info "Editor" editor
info "Resolution" resolution info "Resolution" resolution
info "DE" de info "DE" de
info "WM" wm info "WM" wm
@ -237,6 +238,32 @@ shell_path="off"
shell_version="on" shell_version="on"
# Editor
# Show path to $EDITOR
#
# Default: 'off'
# Values: 'on', 'off'
# Flag: --editor_path
#
# Example:
# on: '/opt/bin/vim'
# off: 'vim'
editor_path="off"
# Show $EDITOR version
#
# Default: 'on'
# Values: 'on', 'off'
# Flag: '--editor_version'
#
# Example:
# on: 'vim 9.0'
# off: 'vim'
editor_version="on"
# CPU # CPU
@ -2065,6 +2092,38 @@ get_shell() {
shell=${shell/\(*\)} shell=${shell/\(*\)}
} }
get_editor() {
local editor_full_path="${VISUAL:-$EDITOR}"
# in case neither is set just return
[[ -z "$editor_full_path" ]] && return
case $editor_path in
on) editor="${editor_full_path} " ;;
off) editor="${editor_full_path##*/} " ;;
esac
# in case editor version is not demanded don't bother parsing it
[[ $editor_version != on ]] && return
case ${editor_name:=${editor_full_path##*/}} in
nano|vim)
editor+=$("$editor_full_path" --version 2>&1)
editor="${editor/$'\n'*}"
editor="${editor/$editor_name }"
;;
*)
editor+=$("$editor_full_path" --version 2>&1)
editor="${editor/$'\n'*}"
;;
esac
# remove some common unwanted info from version strings
editor=${editor/, version}
editor=${editor/options*}
editor=${editor/\(*\)}
}
get_de() { get_de() {
# If function was run, stop here. # If function was run, stop here.
((de_run == 1)) && return ((de_run == 1)) && return
@ -5822,6 +5881,8 @@ INFO:
--gtk3 on/off Enable/Disable gtk3 theme/font/icons output --gtk3 on/off Enable/Disable gtk3 theme/font/icons output
--shell_path on/off Enable/Disable showing \$SHELL path --shell_path on/off Enable/Disable showing \$SHELL path
--shell_version on/off Enable/Disable showing \$SHELL version --shell_version on/off Enable/Disable showing \$SHELL version
--editor_path on/off Enable/Disable showing \$EDITOR path
--editor_version on/off Enable/Disable showing \$EDITOR version
--disk_show value Which disks to display. --disk_show value Which disks to display.
Possible values: '/', '/dev/sdXX', '/path/to/mount point' Possible values: '/', '/dev/sdXX', '/path/to/mount point'
@ -6049,6 +6110,8 @@ get_args() {
"--qt") qt="$2" ;; "--qt") qt="$2" ;;
"--shell_path") shell_path="$2" ;; "--shell_path") shell_path="$2" ;;
"--shell_version") shell_version="$2" ;; "--shell_version") shell_version="$2" ;;
"--editor_path") editor_path="$2" ;;
"--editor_version") editor_version="$2" ;;
"--ip_host") public_ip_host="$2" ;; "--ip_host") public_ip_host="$2" ;;
"--ip_timeout") public_ip_timeout="$2" ;; "--ip_timeout") public_ip_timeout="$2" ;;
"--ip_interface") "--ip_interface")

View file

@ -125,6 +125,12 @@ Enable/Disable showing $SHELL path
\fB\-\-shell_version\fR on/off \fB\-\-shell_version\fR on/off
Enable/Disable showing $SHELL version Enable/Disable showing $SHELL version
.TP .TP
\fB\-\-editor_path\fR on/off
Enable/Disable showing $VISUAL or $EDITOR path
.TP
\fB\-\-editor_version\fR on/off
Enable/Disable showing $VISUAL or $EDITOR version
.TP
\fB\-\-disk_show\fR value \fB\-\-disk_show\fR value
Which disks to display. Which disks to display.
Possible values: '/', '/dev/sdXX', '/path/to/mount point' Possible values: '/', '/dev/sdXX', '/path/to/mount point'