11#! /bin/sh
22
33BASEDIR=$( cd " $( dirname " $0 " ) " ; pwd -P)
4+ GETOPT=getopt
45
56usage () {
67 echo " Usage: $0 [options]"
@@ -12,26 +13,31 @@ usage() {
1213 echo " Display Options"
1314 echo " -c, --cwd Working Directory"
1415 echo " -x, --cmd Executed Command (default: fd --color=never)"
15- echo " -g, --git-icons Git icons [0|1| false|true] (default:false)"
16- echo " -f, --file-icons File icons [0|1| false|true] (default:true)"
17- echo " --color Color icons [0|1| false|true] (default:true)"
16+ echo " -g, --git-icons Git icons [false|true] (default:false)"
17+ echo " -f, --file-icons File icons [false|true] (default:true)"
18+ echo " --color Color icons [false|true] (default:true)"
1819}
1920
2021# saner programming env: these switches turn some bugs into errors
2122set -o noclobber -o nounset
2223
24+ # MacOs: `brew install gnu-getopt && brew link --force gnu-getopt`
25+ if [ -x /usr/local/bin/getopt ]; then
26+ GETOPT=/usr/local/bin/getopt
27+ fi
28+
2329# -allow a command to fail with !’s side effect on errexit
2430# -use return value from ${PIPESTATUS[0]}, because ! hosed $?
25- getopt --test > /dev/null
31+ $GETOPT --test > /dev/null
2632if [ $? -ne 4 ]; then
27- echo ' `getopt --test` failed in this environment.'
33+ echo " ` $GETOPT --test` failed in this environment."
2834 exit 1
2935fi
3036
3137OPTIONS=hd:c:x:f:g:
3238LONGOPTS=help,debug:,cwd:,file-icons:,git-icons:,color:,cmd:
3339
34- PARSED=$( getopt --options=$OPTIONS --longoptions=$LONGOPTS --name " $0 " -- " $@ " )
40+ PARSED=$( $GETOPT --options=$OPTIONS --longoptions=$LONGOPTS --name " $0 " -- " $@ " )
3541if [ $? -ne 0 ]; then
3642 # e.g. return value is 1
3743 # then getopt has complained about wrong arguments to stdout
@@ -55,17 +61,7 @@ while true; do
5561 exit 0
5662 ;;
5763 -d|--debug)
58- case $2 in
59- " 2" |" v" |" verbose" )
60- debug=" v"
61- ;;
62- " 1" |" true" )
63- debug=" true"
64- ;;
65- * )
66- debug=" false"
67- ;;
68- esac
64+ debug=" $2 "
6965 shift 2
7066 ;;
7167 -c|--cwd)
@@ -78,35 +74,21 @@ while true; do
7874 ;;
7975 -f|--file-icons)
8076 case $2 in
81- " 0 " |" false " )
82- file_icons=" false "
77+ " true " |" srv " | " mini " | " devicons " )
78+ file_icons=" $2 "
8379 ;;
8480 * )
85- file_icons=" true "
81+ file_icons=" nil "
8682 ;;
8783 esac
8884 shift 2
8985 ;;
9086 -g|--git-icons)
91- case $2 in
92- " 0" |" false" )
93- git_icons=" false"
94- ;;
95- * )
96- git_icons=" true"
97- ;;
98- esac
87+ git_icons=" $2 "
9988 shift 2
10089 ;;
10190 --color)
102- case $2 in
103- " 0" |" false" )
104- color_icons=" false"
105- ;;
106- * )
107- color_icons=" true"
108- ;;
109- esac
91+ color_icons=" $2 "
11092 shift 2
11193 ;;
11294 --)
@@ -129,18 +111,38 @@ if [ $# -gt 0 ]; then
129111 exit 4
130112fi
131113
132- VIMRUNTIME=/usr/share/nvim/runtime \
133- /usr/bin/nvim -u NONE -l ${BASEDIR} /../lua/fzf-lua/spawn.lua " return
114+ ICONS_PATH=nil
115+ ICONS_SETUP=nil
116+
117+ if [ $file_icons != " nil" ]; then
118+ if [ $file_icons != " mini" ]; then
119+ if [ -d " ${BASEDIR} /../deps/nvim-web-devicons" ]; then
120+ ICONS_PATH=" ${BASEDIR} /../deps/nvim-web-devicons"
121+ else
122+ ICONS_PATH=" ${XDG_DATA_HOME:- $HOME / .local/ share} /nvim/lazy/nvim-web-devicons"
123+ fi
124+ ICONS_SETUP=" ${BASEDIR} /devicons.lua"
125+ else
126+ if [ -d " ${BASEDIR} /../deps/mini.nvim" ]; then
127+ ICONS_PATH=" ${BASEDIR} /../deps/mini.nvim"
128+ else
129+ ICONS_PATH=" ${XDG_DATA_HOME:- $HOME / .local/ share} /nvim/lazy/mini.nvim"
130+ fi
131+ fi
132+ fi
133+
134+ # VIMRUNTIME=/usr/share/nvim/runtime \
135+ nvim -u NONE -l ${BASEDIR} /../lua/fzf-lua/spawn.lua " return
134136 -- opts
135137 {
136138 g = {
137- -- _fzf_lua_server = [[/run/user/1000/fzf-lua.1710687343.12851.1]] ,
138- _devicons_path = [[${XDG_DATA_HOME :- $HOME / .local / share} /nvim/lazy/nvim-web-devicons ]],
139- _devicons_setup = [[${XDG_CONFIG_HOME :- $HOME / .config} /nvim/lua/plugins/devicons/setup.lua ]],
139+ _fzf_lua_server = #[[ ${FZF_LUA_SERVER :- } ]] > 0 and [[ ${FZF_LUA_SERVER :- } ]] or nil ,
140+ _devicons_path = [[${ICONS_PATH} ]],
141+ _devicons_setup = [[${ICONS_SETUP} ]],
140142 },
141143 _base64 = false,
142144 debug = [[$debug ]] == [[v]] and [[v]] or $debug ,
143- file_icons = ${file_icons} ,
145+ file_icons = [[ ${file_icons} ]] == true or [[ ${file_icons} ]] ,
144146 git_icons = ${git_icons} ,
145147 color_icons = ${color_icons} ,
146148 cmd = [[${cmd:- fd --color=never} ]],
0 commit comments