Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
feat: display editor setting
Browse files Browse the repository at this point in the history
Display the configured editor, version and path using the $EDITOR
environment variable similar to the way the shell version is displayed
from the $SHELL variable.

fixes: #2270
  • Loading branch information
m-ildefons committed Dec 28, 2022
1 parent ccd5d9f commit 50ab444
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions neofetch
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ print_info() {
info "Uptime" uptime
info "Packages" packages
info "Shell" shell
info "Editor" editor
info "Resolution" resolution
info "DE" de
info "WM" wm
Expand Down Expand Up @@ -224,6 +225,32 @@ shell_path="off"
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
Expand Down Expand Up @@ -1768,6 +1795,33 @@ get_shell() {
shell=${shell/\(*\)}
}

get_editor() {
local editor_full_path="${VISUAL:-$EDITOR}"

case $editor_path in
on) editor="${editor_full_path} " ;;
off) editor="${editor_full_path##*/} " ;;
esac

[[ $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

editor=${editor/, version}
editor=${editor/options*}
editor=${editor/\(*\)}
}

get_de() {
# If function was run, stop here.
((de_run == 1)) && return
Expand Down Expand Up @@ -5047,6 +5101,8 @@ INFO:
--gtk3 on/off Enable/Disable gtk3 theme/font/icons output
--shell_path on/off Enable/Disable showing \$SHELL path
--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.
Possible values: '/', '/dev/sdXX', '/path/to/mount point'
Expand Down Expand Up @@ -5263,6 +5319,8 @@ get_args() {
"--gtk3") gtk3="$2" ;;
"--shell_path") shell_path="$2" ;;
"--shell_version") shell_version="$2" ;;
"--editor_path") editor_path="$2" ;;
"--editor_version") editor_version="$2" ;;
"--ip_host") public_ip_host="$2" ;;
"--ip_timeout") public_ip_timeout="$2" ;;
"--ip_interface")
Expand Down

0 comments on commit 50ab444

Please sign in to comment.