mirror of
https://github.com/oSoWoSo/DistroHopper.git
synced 2024-08-14 22:46:53 +00:00
quickfzf: Added ability to edit VM's config files
This commit is contained in:
parent
896b1b5a60
commit
b8bf944f2e
1 changed files with 28 additions and 20 deletions
46
quickfzf
46
quickfzf
|
@ -6,7 +6,8 @@
|
||||||
|
|
||||||
# Define variables
|
# Define variables
|
||||||
progname="${progname:="${0##*/}"}"
|
progname="${progname:="${0##*/}"}"
|
||||||
version="0.22"
|
version="0.23"
|
||||||
|
#EDITOR="nano"
|
||||||
vms=(*.conf)
|
vms=(*.conf)
|
||||||
|
|
||||||
# Set traps to catch the signals and exit gracefully
|
# Set traps to catch the signals and exit gracefully
|
||||||
|
@ -24,9 +25,16 @@ fi
|
||||||
|
|
||||||
QUICKGET=$(command -v quickget) || exit 255
|
QUICKGET=$(command -v quickget) || exit 255
|
||||||
|
|
||||||
# Display version and prepared VMs
|
# Display header
|
||||||
#printf " $progname: $version\n quickemu: $(quickemu --version)\n\n Prepared VMs:\n-------------\n"
|
printf '%s: v.%s\nquickemu: v.%s\n' "$progname" "$version" "$(quickemu --version)"
|
||||||
printf '%s: v.%s\nquickemu: v.%s\n\n Workdir: %s\n\n Prepared VMs:\n-------------\n' "$progname" "$version" "$(quickemu --version)" "$(pwd)"
|
if [ -z "$EDITOR" ]
|
||||||
|
then
|
||||||
|
echo "editor: Not set! edit configs will not work!"
|
||||||
|
else
|
||||||
|
echo "editor: $EDITOR"
|
||||||
|
fi
|
||||||
|
printf '\n Workdir: %s\n\n Prepared VMs:\n-------------\n' "$(pwd)"
|
||||||
|
|
||||||
# Check if there are any VMs
|
# Check if there are any VMs
|
||||||
if [ ${#vms[@]} -eq 0 ]; then
|
if [ ${#vms[@]} -eq 0 ]; then
|
||||||
echo "No VMs found."
|
echo "No VMs found."
|
||||||
|
@ -37,20 +45,21 @@ fi
|
||||||
printf "%s\n" "${vms[@]%.*}"
|
printf "%s\n" "${vms[@]%.*}"
|
||||||
echo "-------------"
|
echo "-------------"
|
||||||
|
|
||||||
|
printf 'Press CTRL+c anytime to kill %s\n\n' "$progname"
|
||||||
|
|
||||||
# Action prompt
|
# Action prompt
|
||||||
printf " Do you want to create a new VM? (c)
|
printf " Do you want to create a new VM? (c)
|
||||||
|
edit VM's config file (e)
|
||||||
or run an existing one? (press anything)\n"
|
or run an existing one? (press anything)\n"
|
||||||
read -rn 1 -s start
|
read -rn 1 -s start
|
||||||
case $start in
|
case $start in
|
||||||
c )
|
c ) todo="create";;
|
||||||
todo="create"
|
e ) todo="edit";;
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# If the user chose to create a new VM
|
# If the user chose to create a new VM
|
||||||
if [ "$todo" = "create" ]; then
|
if [ "$todo" = "create" ]; then
|
||||||
os=$(quickget | sed 1d | cut -d':' -f2 | grep -o '[^ ]*' | fzf --cycle --header='Choose OS to download
|
os=$(quickget | sed 1d | cut -d':' -f2 | grep -o '[^ ]*' | fzf --cycle --header='Choose OS to download')
|
||||||
or CTRL-c or ESC to quit')
|
|
||||||
# If the OS is Windows
|
# If the OS is Windows
|
||||||
if [ "$os" = windows ]; then
|
if [ "$os" = windows ]; then
|
||||||
answer=$(echo "Default English
|
answer=$(echo "Default English
|
||||||
|
@ -63,8 +72,7 @@ Choose other language" | fzf --cycle)
|
||||||
# get window language list
|
# get window language list
|
||||||
wlend=$(($(cat $QUICKGET | sed '/Arabic/,$!d' | grep -n '}' | cut -d':' -f1 | head -n 1) - 1))
|
wlend=$(($(cat $QUICKGET | sed '/Arabic/,$!d' | grep -n '}' | cut -d':' -f1 | head -n 1) - 1))
|
||||||
# get windows language
|
# get windows language
|
||||||
wlang=$(cat $QUICKGET | sed '/Arabic/,$!d' | head -n $wlend | cut -d'=' -f2 | tail -c +2 | head -c -2 | sed 's/^[ \t]*//' | fzf --cycle --header='Choose Language
|
wlang=$(cat $QUICKGET | sed '/Arabic/,$!d' | head -n $wlend | cut -d'=' -f2 | tail -c +2 | head -c -2 | sed 's/^[ \t]*//' | fzf --cycle --header='Choose Language')
|
||||||
or CTRL-c or ESC to quit')
|
|
||||||
# downloading windows
|
# downloading windows
|
||||||
printf '\n Trying to download Windows %s %s...\n\n' "$wrelease" "$wlang"
|
printf '\n Trying to download Windows %s %s...\n\n' "$wrelease" "$wlang"
|
||||||
quickget "windows" "$wrelease" "$wlang"
|
quickget "windows" "$wrelease" "$wlang"
|
||||||
|
@ -74,26 +82,26 @@ Choose other language" | fzf --cycle)
|
||||||
choices=$(quickget "$os" | sed 1d)
|
choices=$(quickget "$os" | sed 1d)
|
||||||
if [ "$(echo "$choices" | wc -l)" = 1 ]; then
|
if [ "$(echo "$choices" | wc -l)" = 1 ]; then
|
||||||
# get release
|
# get release
|
||||||
release=$(echo "$choices" | grep 'Releases' | cut -d':' -f2 | grep -o '[^ ]*' | fzf --cycle --header='Choose Release
|
release=$(echo "$choices" | grep 'Releases' | cut -d':' -f2 | grep -o '[^ ]*' | fzf --cycle --header='Choose Release')
|
||||||
or CTRL-c or ESC to quit')
|
|
||||||
# downloading
|
# downloading
|
||||||
printf '\n Trying to download %s %s...\n\n' "$os" "$release"
|
printf '\n Trying to download %s %s...\n\n' "$os" "$release"
|
||||||
quickget "$os" "$release"
|
quickget "$os" "$release"
|
||||||
else
|
else
|
||||||
# get release
|
# get release
|
||||||
release=$(echo "$choices" | grep 'Releases' | cut -d':' -f2 | grep -o '[^ ]*' | fzf --cycle --header='Choose Release
|
release=$(echo "$choices" | grep 'Releases' | cut -d':' -f2 | grep -o '[^ ]*' | fzf --cycle --header='Choose Release')
|
||||||
or CTRL-c or ESC to quit')
|
|
||||||
# get edition
|
# get edition
|
||||||
edition=$(echo "$choices" | grep 'Editions' | cut -d':' -f2 | grep -o '[^ ]*' | fzf --cycle --header='Choose Edition
|
edition=$(echo "$choices" | grep 'Editions' | cut -d':' -f2 | grep -o '[^ ]*' | fzf --cycle --header='Choose Edition')
|
||||||
or CTRL-c or ESC to quit')
|
|
||||||
# downloading
|
# downloading
|
||||||
printf '\n Trying to download %s %s %s...\n\n' "$os" "$release" "$edition"
|
printf '\n Trying to download %s %s %s...\n\n' "$os" "$release" "$edition"
|
||||||
quickget "$os" "$release" "$edition"
|
quickget "$os" "$release" "$edition"
|
||||||
fi
|
fi
|
||||||
|
elif [ "$todo" = "edit" ]; then
|
||||||
|
editconfig=$(ls | grep '.conf' | fzf --cycle --header='Choose config to edit')
|
||||||
|
"$EDITOR" "$editconfig"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# choose VM to run
|
# choose VM to run
|
||||||
chosen=$(echo "$(ls *.conf 2>/dev/null | sed 's/\.conf$//')" | fzf --cycle --header='Choose VM to run
|
chosen=$(echo "$(ls *.conf 2>/dev/null | sed 's/\.conf$//')" | fzf --cycle --header='Choose VM to run')
|
||||||
or CTRL-c or ESC to quit')
|
|
||||||
|
|
||||||
# Run chosen VM
|
# Run chosen VM
|
||||||
printf '\n Starting %s...\n\n' "$chosen"
|
printf '\n Starting %s...\n\n' "$chosen"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue