refactor(bin): mise-config script now uses fd
This commit is contained in:
parent
0f3306c1d3
commit
a4e6d0597c
2 changed files with 18 additions and 23 deletions
|
@ -1,23 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
TEMPLATE_DIR="$XDG_CONFIG_HOME/mise/templates"
|
|
||||||
MISE_CONFIG=".mise.toml"
|
|
||||||
|
|
||||||
if [ ! -d "$TEMPLATE_DIR" ]; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
selected_file=$(find "$TEMPLATE_DIR" -name "*.toml" -print0 |
|
|
||||||
xargs -0 -n 1 basename | sed 's/\.toml$//' |
|
|
||||||
fzf --preview "bat --style=numbers --color=always $TEMPLATE_DIR/{}.toml" \
|
|
||||||
--prompt="Select a template file: ")
|
|
||||||
|
|
||||||
if [ -z "$selected_file" ]; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f "$MISE_CONFIG" ]; then
|
|
||||||
cat "$TEMPLATE_DIR/$selected_file.toml" >>"$MISE_CONFIG"
|
|
||||||
else
|
|
||||||
cp "$TEMPLATE_DIR/$selected_file.toml" "$MISE_CONFIG"
|
|
||||||
fi
|
|
18
.local/bin/mise-config
Executable file
18
.local/bin/mise-config
Executable file
|
@ -0,0 +1,18 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
TEMPLATE_DIR="$XDG_CONFIG_HOME/mise/templates"
|
||||||
|
MISE_CONFIG=".mise.toml"
|
||||||
|
|
||||||
|
if [ ! -d "$TEMPLATE_DIR" ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
selected_file=$(fd . "$TEMPLATE_DIR" -e toml -x basename {} |
|
||||||
|
fzf --preview "bat $TEMPLATE_DIR/{}" \
|
||||||
|
--prompt="Select a template file: ")
|
||||||
|
|
||||||
|
if [ -z "$selected_file" ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cp -i "$TEMPLATE_DIR/$selected_file" "$MISE_CONFIG"
|
Loading…
Add table
Reference in a new issue