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

Commit 50ab444

Browse files
committed
feat: display editor setting
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
1 parent ccd5d9f commit 50ab444

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

neofetch

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ print_info() {
6262
info "Uptime" uptime
6363
info "Packages" packages
6464
info "Shell" shell
65+
info "Editor" editor
6566
info "Resolution" resolution
6667
info "DE" de
6768
info "WM" wm
@@ -224,6 +225,32 @@ shell_path="off"
224225
shell_version="on"
225226
226227
228+
# Editor
229+
230+
231+
# Show path to $EDITOR
232+
#
233+
# Default: 'off'
234+
# Values: 'on', 'off'
235+
# Flag: --editor_path
236+
#
237+
# Example:
238+
# on: '/opt/bin/vim'
239+
# off: 'vim'
240+
editor_path="off"
241+
242+
# Show $EDITOR version
243+
#
244+
# Default: 'on'
245+
# Values: 'on', 'off'
246+
# Flag: '--editor_version'
247+
#
248+
# Example:
249+
# on: 'vim 9.0'
250+
# off: 'vim'
251+
editor_version="on"
252+
253+
227254
# CPU
228255
229256
@@ -1768,6 +1795,33 @@ get_shell() {
17681795
shell=${shell/\(*\)}
17691796
}
17701797

1798+
get_editor() {
1799+
local editor_full_path="${VISUAL:-$EDITOR}"
1800+
1801+
case $editor_path in
1802+
on) editor="${editor_full_path} " ;;
1803+
off) editor="${editor_full_path##*/} " ;;
1804+
esac
1805+
1806+
[[ $editor_version != on ]] && return
1807+
1808+
case ${editor_name:=${editor_full_path##*/}} in
1809+
nano|vim)
1810+
editor+=$("$editor_full_path" --version 2>&1)
1811+
editor="${editor/$'\n'*}"
1812+
editor="${editor/$editor_name }"
1813+
;;
1814+
*)
1815+
editor+=$("$editor_full_path" --version 2>&1)
1816+
editor="${editor/$'\n'*}"
1817+
;;
1818+
esac
1819+
1820+
editor=${editor/, version}
1821+
editor=${editor/options*}
1822+
editor=${editor/\(*\)}
1823+
}
1824+
17711825
get_de() {
17721826
# If function was run, stop here.
17731827
((de_run == 1)) && return
@@ -5047,6 +5101,8 @@ INFO:
50475101
--gtk3 on/off Enable/Disable gtk3 theme/font/icons output
50485102
--shell_path on/off Enable/Disable showing \$SHELL path
50495103
--shell_version on/off Enable/Disable showing \$SHELL version
5104+
--editor_path on/off Enable/Disable showing \$EDITOR path
5105+
--editor_version on/off Enable/Disable showing \$EDITOR version
50505106
--disk_show value Which disks to display.
50515107
Possible values: '/', '/dev/sdXX', '/path/to/mount point'
50525108
@@ -5263,6 +5319,8 @@ get_args() {
52635319
"--gtk3") gtk3="$2" ;;
52645320
"--shell_path") shell_path="$2" ;;
52655321
"--shell_version") shell_version="$2" ;;
5322+
"--editor_path") editor_path="$2" ;;
5323+
"--editor_version") editor_version="$2" ;;
52665324
"--ip_host") public_ip_host="$2" ;;
52675325
"--ip_timeout") public_ip_timeout="$2" ;;
52685326
"--ip_interface")

0 commit comments

Comments
 (0)