diff --git a/opt/cs50/bin/code b/opt/cs50/bin/code index 5a7686b8..5604ea0f 100755 --- a/opt/cs50/bin/code +++ b/opt/cs50/bin/code @@ -1,5 +1,9 @@ #!/bin/bash +# Formatting +bold=$(tput bold) +normal=$(tput sgr0) + # Check whether run with any options options=false for arg in "$@"; do @@ -14,7 +18,7 @@ if [ "$options" = false ]; then # If no arguments if [ $# -eq 0 ]; then - read -p "Are you sure you want to run $(tput bold)code$(tput sgr0) without a filename? It would open a new tab. [y/N] " -r + read -p "Are you sure you want to run ${bold}code${normal} without a filename? It would open a new tab. [y/N] " -r if [[ ! "${REPLY,,}" =~ ^y|yes$ ]]; then exit 1 fi @@ -28,7 +32,7 @@ if [ "$options" = false ]; then # If a directory if [ -d "$arg" ]; then - read -p "Are you sure you want to open $(tput bold)$arg$(tput sgr0)? It's a folder, not a file, so it would open in a new tab. [y/N] " -r + read -p "Are you sure you want to open ${bold}${arg}${normal}? It's a folder, not a file, so it would open in a new tab. [y/N] " -r if [[ ! "${REPLY,,}" =~ ^y|yes$ ]]; then exit 1 fi @@ -39,7 +43,7 @@ if [ "$options" = false ]; then # If first letter is capitalized but one of these languages if [[ "$arg" =~ ^[A-Z].*\.(c|css|html|js|py)$ ]]; then - read -p "Are you sure you want to create $(tput bold)$arg$(tput sgr0)? Filenames aren't usually capitalized. [y/N] " -r + read -p "Are you sure you want to create ${bold}${arg}${normal}? Filenames aren't usually capitalized. [y/N] " -r if [[ ! "${REPLY,,}" =~ ^y|yes$ ]]; then exit 1 fi @@ -47,7 +51,7 @@ if [ "$options" = false ]; then # If first letter is lowercase but Java if [[ "$arg" =~ ^[a-z].*\.java$ ]]; then - read -p "Are you sure you want to create $(tput bold)$arg$(tput sgr0)? Filenames are usually capitalized. [y/N] " -r + read -p "Are you sure you want to create ${bold}${arg}${normal}? Filenames are usually capitalized. [y/N] " -r if [[ ! "${REPLY,,}" =~ ^y|yes$ ]]; then exit 1 fi @@ -55,7 +59,7 @@ if [ "$options" = false ]; then # If file doesn't have an extension if [[ ! "$arg" =~ \.[^.]+$ ]]; then - read -p "Are you sure you want to create $(tput bold)$arg$(tput sgr0)? Filenames usually have extensions. [y/N] " -r + read -p "Are you sure you want to create ${bold}${arg}${normal}? Filenames usually have extensions. [y/N] " -r if [[ ! "${REPLY,,}" =~ ^y|yes$ ]]; then exit 1 fi @@ -63,7 +67,7 @@ if [ "$options" = false ]; then # If file extension is capitalized if [[ "$arg" =~ \.[A-Z]+$ ]]; then - read -p "Are you sure you want to create $(tput bold)$arg$(tput sgr0)? File extensions aren't usually capitalized. [y/N] " -r + read -p "Are you sure you want to create ${bold}${arg}${normal}? File extensions aren't usually capitalized. [y/N] " -r if [[ ! "${REPLY,,}" =~ ^y|yes$ ]]; then exit 1 fi