• May 13, 2023 •LeifMessinger
0 likes • 8 views
#!/bin/bash # Turns 4 spaces into tabs. # Mostly stolen from AI # Define the directory to process DIRECTORY=$1 TabCount=${2:-'4'} #Defaults to 4 # Check if directory is specified if [ -z "$DIRECTORY" ]; then echo "Error: Directory not specified." exit 1 fi # Check if directory exists if [ ! -d "$DIRECTORY" ]; then echo "Error: Directory does not exist." exit 1 fi # Find all files in directory and subdirectories FILES=$(find "$DIRECTORY" -type f) # Loop through each file and unexpand it for FILE in $FILES; do unexpand -t "$TabCount" "$FILE" > "$FILE.tmp" mv "$FILE.tmp" "$FILE" done echo "Done!"
• Sep 29, 2021 •LeifMessinger
0 likes • 29 views
#!/bin/bash #cpcmd.sh [file1 [file2...]] #Prints out the commands needed to copy the file to your local machine #This will work on any server that also has the same hostname as in your hosts file. #I should update this to detect if a file is a directory, and enable recursion for those commands. If you do it now, it will probably just warn you. if [ -n "$1" ]; then for arg; do recursive=$(if [[ -d $arg ]]; then printf " -r"; fi) printf "scp$recursive \"$(whoami)@$(hostname):" printf `readlink -f $arg` printf "\" .\n" done else echo "scp \"$(whoami)@$(hostname):$PWD/*\" ." fi #-----------EDIT: #On the UNT cell machines, you have to do this script instead ##!/bin/bash #if [ -n "$1" ]; then # for arg; do # recursive=$(if [[ -d $arg ]]; then printf " -r"; fi) # printf "scp$recursive $(whoami)@$(hostname).eng.unt.edu:" # printf `readlink -f $arg` # printf " .\n" # done #else # echo "scp $(whoami)@$(hostname).eng.unt.edu:$PWD/* ." #fi
• Jul 16, 2023 •LeifMessinger
0 likes • 6 views
#!/bin/bash sudo apt install build-essential vulkan-tools libvulkan-dev vulkan-validationlayers-dev spirv-tools libglfw3-dev libglm-dev libtinyobjloader-dev #The rest of this downloads the Vulkan Tutorial project and its dependencies. #Comment this out to keep going exit sudo apt install git cmake cmake-gui sudo mkdir /usr/lib/stb pushd /usr/lib/stb sudo wget https://raw.githubusercontent.com/nothings/stb/master/stb_image.h popd cd ~/Documents git clone https://github.com/Overv/VulkanTutorial.git cd VulkanTutorial/code cmake -S . -B build -DCMAKE_INSTALL_PREFIX:PATH="/usr/local" -DSTB_INCLUDEDIR:PATH="/usr/lib/stb" cd build make
• Sep 9, 2023 •LeifMessinger
0 likes • 3 views
#!/bin/bash #Changes the remote url from https to ssh. #Only works for github, because I'd have to store a dictionary of every https to ssh url otherwise. #Made using Bing Chat # Get the remote URL from the console REPO_URL=$(git config --get remote.origin.url) # Check that REPO_URL contains https://github.com if [[ $REPO_URL == *"https://github.com"* ]]; then # Replace https with ssh in the URL REPO_URL=${REPO_URL/https:\/\/github.com\//[email protected]:} # Change the remote URL to the SSH version git remote set-url origin "$REPO_URL" else echo "Error: REPO_URL does not contain https://github.com" >&2 exit 1 fi
• Nov 18, 2022 •AustinLeath
0 likes • 1 view
# # Austin Leath # checks for /Desktop symlink. Creates the symlink if it doesnt already exist # #Fetch the target user if desired, otherwise use the currently logged in user. if [ "$4" != "" ]; then TARGET_USER=$4 else TARGET_USER=$3 fi if [ "$5" != "" ]; then DIRECTORY_NAME=$5 else TARGET_USER="$3 Desktop" fi # Functions CHECK_SYMLINK() { if test -f "/Desktop"; then echo "/Desktop exists" else echo "/Desktop does not exist" fi } CHECK_SYNTHETIC_CONF() { if test -f "/etc/synthetic.conf"; then echo "/etc/synthetic.conf exists" else echo "/etc/synthetic.conf does not exist" fi } CREATE_SYMLINK() { if [[ $(CHECK_SYNTHETIC_CONF) != "/etc/synthetic.conf exists" ]]; then echo "/etc/synthetic.conf does not exist. creating.." touch /etc/synthetic.conf chown -R root:wheel /etc/synthetic.conf fi if grep -q "$DIRECTORY_NAME" /etc/synthetic.conf; then echo "$DIRECTORY_NAME already exists" exit 1 else echo "$DIRECTORY_NAME\t/Users/$TARGET_USER/Desktop" >> /etc/synthetic.conf fi echo "/Desktop symbolic link created" } if [[ $(CHECK_SYMLINK) != "/Desktop exists" ]]; then CREATE_SYMLINK fi exit 0
• Mar 10, 2023 •Helper
1 like • 6 views
#!/bin/bash for branch in $(git branch | cut -c 3-); do read -p "Delete local branch $branch? (y/n) " -n 1 -r echo "" if [[ $REPLY =~ ^[Yy]$ ]]; then git branch -D $branch fi done