mirror of
https://github.com/jimeh/dotfiles.git
synced 2026-02-19 13:46:41 +00:00
chore(cursor): minor tweaks to setup.sh helper script
This commit is contained in:
206
cursor/setup.sh
206
cursor/setup.sh
@@ -27,13 +27,13 @@ get_extensions_lock() {
|
|||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
|
|
||||||
show_help() {
|
show_help() {
|
||||||
cat <<EOF
|
cat << EOF
|
||||||
Usage: $(basename "$0") EDITOR COMMAND
|
Usage: $(basename "$0") EDITOR COMMAND
|
||||||
|
|
||||||
Editors:
|
Editors:
|
||||||
cursor Cursor editor
|
cursor Cursor editor
|
||||||
vscode Visual Studio Code
|
vscode, vsc Visual Studio Code
|
||||||
vscode-insiders Visual Studio Code Insiders
|
vscode-insiders, vsci Visual Studio Code Insiders
|
||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
config, conf Create symlinks for editor config files
|
config, conf Create symlinks for editor config files
|
||||||
@@ -54,44 +54,44 @@ EOF
|
|||||||
# Determine editor config directory
|
# Determine editor config directory
|
||||||
editor_config_dir() {
|
editor_config_dir() {
|
||||||
case "$(uname -s)" in
|
case "$(uname -s)" in
|
||||||
"Darwin")
|
"Darwin")
|
||||||
case "${SETUP_EDITOR}" in
|
case "${SETUP_EDITOR}" in
|
||||||
"cursor")
|
"cursor")
|
||||||
echo "${HOME}/Library/Application Support/Cursor/User"
|
echo "${HOME}/Library/Application Support/Cursor/User"
|
||||||
|
;;
|
||||||
|
"vscode")
|
||||||
|
echo "${HOME}/Library/Application Support/Code/User"
|
||||||
|
;;
|
||||||
|
"vscode-insiders")
|
||||||
|
echo "${HOME}/Library/Application Support/Code - Insiders/User"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Error: Invalid editor '${SETUP_EDITOR}' for macOS"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
;;
|
;;
|
||||||
"vscode")
|
"Linux")
|
||||||
echo "${HOME}/Library/Application Support/Code/User"
|
case "${SETUP_EDITOR}" in
|
||||||
;;
|
"cursor")
|
||||||
"vscode-insiders")
|
echo "${HOME}/.config/Cursor/User"
|
||||||
echo "${HOME}/Library/Application Support/Code - Insiders/User"
|
;;
|
||||||
|
"vscode")
|
||||||
|
echo "${HOME}/.config/Code/User"
|
||||||
|
;;
|
||||||
|
"vscode-insiders")
|
||||||
|
echo "${HOME}/.config/Code - Insiders/User"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Error: Invalid editor '${SETUP_EDITOR}' for Linux"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Error: Invalid editor '${SETUP_EDITOR}' for macOS"
|
echo "Error: Unsupported operating system"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
|
||||||
;;
|
|
||||||
"Linux")
|
|
||||||
case "${SETUP_EDITOR}" in
|
|
||||||
"cursor")
|
|
||||||
echo "${HOME}/.config/Cursor/User"
|
|
||||||
;;
|
|
||||||
"vscode")
|
|
||||||
echo "${HOME}/.config/Code/User"
|
|
||||||
;;
|
|
||||||
"vscode-insiders")
|
|
||||||
echo "${HOME}/.config/Code - Insiders/User"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Error: Invalid editor '${SETUP_EDITOR}' for Linux"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Error: Unsupported operating system"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,37 +142,37 @@ find_editor_cmd() {
|
|||||||
local editor_cmd=""
|
local editor_cmd=""
|
||||||
|
|
||||||
case "${SETUP_EDITOR}" in
|
case "${SETUP_EDITOR}" in
|
||||||
"cursor")
|
"cursor")
|
||||||
# Check for cursor CLI in multiple possible locations
|
# Check for cursor CLI in multiple possible locations
|
||||||
for cmd in "cursor" "/Applications/Cursor.app/Contents/Resources/app/bin/cursor" "${HOME}/Applications/Cursor.app/Contents/Resources/app/bin/cursor"; do
|
for cmd in "cursor" "/Applications/Cursor.app/Contents/Resources/app/bin/cursor" "${HOME}/Applications/Cursor.app/Contents/Resources/app/bin/cursor"; do
|
||||||
if command -v "${cmd}" >/dev/null 2>&1; then
|
if command -v "${cmd}" > /dev/null 2>&1; then
|
||||||
editor_cmd="${cmd}"
|
editor_cmd="${cmd}"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
"vscode")
|
"vscode")
|
||||||
# Check for VSCode CLI in multiple possible locations
|
# Check for VSCode CLI in multiple possible locations
|
||||||
for cmd in "code" "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code" "${HOME}/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code"; do
|
for cmd in "code" "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code" "${HOME}/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code"; do
|
||||||
if command -v "${cmd}" >/dev/null 2>&1; then
|
if command -v "${cmd}" > /dev/null 2>&1; then
|
||||||
editor_cmd="${cmd}"
|
editor_cmd="${cmd}"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
"vscode-insiders")
|
"vscode-insiders")
|
||||||
# Check for VSCode Insiders CLI in multiple possible locations
|
# Check for VSCode Insiders CLI in multiple possible locations
|
||||||
for cmd in "code-insiders" "/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code" "${HOME}/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code"; do
|
for cmd in "code-insiders" "/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code" "${HOME}/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code"; do
|
||||||
if command -v "${cmd}" >/dev/null 2>&1; then
|
if command -v "${cmd}" > /dev/null 2>&1; then
|
||||||
editor_cmd="${cmd}"
|
editor_cmd="${cmd}"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Error: Invalid editor '${SETUP_EDITOR}'"
|
echo "Error: Invalid editor '${SETUP_EDITOR}'"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [[ -z "${editor_cmd}" ]]; then
|
if [[ -z "${editor_cmd}" ]]; then
|
||||||
@@ -197,7 +197,7 @@ do_dump_extensions() {
|
|||||||
echo "# Generated on ${current_date}"
|
echo "# Generated on ${current_date}"
|
||||||
echo
|
echo
|
||||||
"${editor_cmd}" --list-extensions --show-versions
|
"${editor_cmd}" --list-extensions --show-versions
|
||||||
} >"${extensions_lock}"
|
} > "${extensions_lock}"
|
||||||
|
|
||||||
echo "Extensions list dumped to ${extensions_lock}"
|
echo "Extensions list dumped to ${extensions_lock}"
|
||||||
}
|
}
|
||||||
@@ -282,10 +282,10 @@ do_install_extensions() {
|
|||||||
# Clean up the .vsix file after installation attempt
|
# Clean up the .vsix file after installation attempt
|
||||||
rm "${vsix_path}"
|
rm "${vsix_path}"
|
||||||
fi
|
fi
|
||||||
done <"${extensions_lock}"
|
done < "${extensions_lock}"
|
||||||
|
|
||||||
# Clean up extensions directory if empty
|
# Clean up extensions directory if empty
|
||||||
rmdir "${extensions_cache_dir}" 2>/dev/null || true
|
rmdir "${extensions_cache_dir}" 2> /dev/null || true
|
||||||
echo "Extensions installation complete!"
|
echo "Extensions installation complete!"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,20 +309,20 @@ main() {
|
|||||||
# Set editor from first argument
|
# Set editor from first argument
|
||||||
editor="$(echo "${1}" | tr '[:upper:]' '[:lower:]')"
|
editor="$(echo "${1}" | tr '[:upper:]' '[:lower:]')"
|
||||||
case "${editor}" in
|
case "${editor}" in
|
||||||
"vscode" | "code")
|
"vscode" | "code" | "vsc" | "v")
|
||||||
SETUP_EDITOR="vscode"
|
SETUP_EDITOR="vscode"
|
||||||
;;
|
;;
|
||||||
"vscode-insiders" | "code-insiders" | "insiders")
|
"vscode-insiders" | "code-insiders" | "insiders" | "vsci" | "i")
|
||||||
SETUP_EDITOR="vscode-insiders"
|
SETUP_EDITOR="vscode-insiders"
|
||||||
;;
|
;;
|
||||||
"cursor")
|
"cursor" | "c")
|
||||||
SETUP_EDITOR="cursor"
|
SETUP_EDITOR="cursor"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Error: Unsupported editor '${editor}'"
|
echo "Error: Unsupported editor '${editor}'"
|
||||||
echo "Supported editors: cursor, vscode, vscode-insiders"
|
echo "Supported editors: cursor, vscode (vsc), vscode-insiders (vsci)"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Get command from second argument
|
# Get command from second argument
|
||||||
@@ -330,25 +330,25 @@ main() {
|
|||||||
|
|
||||||
# Handle commands
|
# Handle commands
|
||||||
case "${command}" in
|
case "${command}" in
|
||||||
"config" | "conf")
|
"config" | "conf")
|
||||||
do_symlink
|
do_symlink
|
||||||
;;
|
;;
|
||||||
"dump-extensions" | "dump")
|
"dump-extensions" | "dump")
|
||||||
do_dump_extensions
|
do_dump_extensions
|
||||||
;;
|
;;
|
||||||
"extensions" | "ext")
|
"extensions" | "ext")
|
||||||
do_install_extensions
|
do_install_extensions
|
||||||
;;
|
;;
|
||||||
"")
|
"")
|
||||||
echo "Error: No command provided"
|
echo "Error: No command provided"
|
||||||
show_help
|
show_help
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Error: Unknown command '${command}'"
|
echo "Error: Unknown command '${command}'"
|
||||||
show_help
|
show_help
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user