created utility for bulk file renaming
This commit is contained in:
@@ -1,113 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
error() {
|
||||
echo "Your package manager is not supported."
|
||||
echo "$COMMAND could not be installed automatically."
|
||||
echo "Please install $COMMAND manually before running this script."
|
||||
exit 1
|
||||
}
|
||||
|
||||
install() {
|
||||
COMMAND=$1
|
||||
PACKAGE=$2
|
||||
|
||||
if ! command -v $COMMAND &> /dev/null
|
||||
then
|
||||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||
echo "$COMMAND not found. Installing $PACKAGE..."
|
||||
|
||||
DISTRO=$(cat /etc/os-release | grep -oP '(?<=^ID=).+' | tr -d '"')
|
||||
|
||||
if [[ $DISTRO == "arch" ]]; then
|
||||
yes | sudo pacman -S $PACKAGE
|
||||
yes | sudo pacman -S $COMMAND
|
||||
exit 0
|
||||
elif [[ $DISTRO == "archarm" ]]; then
|
||||
yes | sudo pacman -S $PACKAGE
|
||||
yes | sudo pacman -S $COMMAND
|
||||
exit 0
|
||||
elif [[ $DISTRO == "ubuntu" ]]; then
|
||||
yes | sudo apt-get install $PACKAGE
|
||||
yes | sudo apt-get install $COMMAND
|
||||
exit 0
|
||||
elif [[ $DISTRO == "fedora" ]]; then
|
||||
yes | sudo dnf install $PACKAGE
|
||||
yes | sudo dnf install $COMMAND
|
||||
exit 0
|
||||
elif [[ $DISTRO == "centos" ]]; then
|
||||
yes | sudo yum install $PACKAGE
|
||||
yes | sudo yum install $COMMAND
|
||||
exit 0
|
||||
elif [[ $DISTRO == "debian" ]]; then
|
||||
yes | sudo apt install $PACKAGE
|
||||
yes | sudo apt install $COMMAND
|
||||
exit 0
|
||||
else
|
||||
error
|
||||
fi
|
||||
|
||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
echo "$COMMAND not found. Installing $PACKAGE..."
|
||||
|
||||
if command -v "brew" &> /dev/null
|
||||
then
|
||||
yes | brew install $PACKAGE
|
||||
yes | brew install $COMMAND
|
||||
|
||||
elif command -v "port" &> /dev/null
|
||||
then
|
||||
yes | sudo port install $PACKAGE
|
||||
yes | sudo port install $COMMAND
|
||||
else
|
||||
echo "Homebrew or MacPorts not found. Please install one of them before running this script."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
error
|
||||
fi
|
||||
else
|
||||
echo "Package $PACKAGE is already installed."
|
||||
fi
|
||||
}
|
||||
|
||||
# If the number of arguments is not 2, print the usage
|
||||
if [[ $# -ne 2 ]]; then
|
||||
echo "Usage: check-dependency <command> <package>"
|
||||
echo " check-dependency <--git> <user/repo>"
|
||||
echo "Checks if a command is installed and if not, installs the package."
|
||||
echo "If --git is specified, it will check if the git repository is executable."
|
||||
echo "Supported package managers: apt, pacman, dnf, yum, brew, port"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
COMMAND=$1
|
||||
PACKAGE=$2
|
||||
|
||||
# If the command is git, we will clone the repository and install it
|
||||
if [[ "$COMMAND" == "--git" ]]; then
|
||||
USER=$(echo $PACKAGE | cut -d'/' -f1)
|
||||
REPO=$(echo $PACKAGE | cut -d'/' -f2)
|
||||
|
||||
# If the repository is not installed, we will clone it and install it
|
||||
if ! command -v $REPO &> /dev/null
|
||||
then
|
||||
THIS_USER=$SUDO_USER
|
||||
|
||||
if [ ! -d /home/$THIS_USER/build ]; then
|
||||
echo "Creating build directory for user $THIS_USER..."
|
||||
su $THIS_USER -c "mkdir /home/$THIS_USER/build"
|
||||
fi
|
||||
|
||||
cd /home/$THIS_USER/build
|
||||
git clone https://github.com/$USER/$REPO
|
||||
cd $REPO
|
||||
inst
|
||||
exit 0
|
||||
|
||||
else
|
||||
echo "Repository $PACKAGE is already installed."
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
install $COMMAND $PACKAGE
|
||||
fi
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
help ()
|
||||
{
|
||||
echo "
|
||||
A small utility to easily and quickly rename files in bulk based upon a
|
||||
pattern.
|
||||
|
||||
Proper Usage:
|
||||
file-rename-pattern "S2 " "episode-" { --dry-run | -d }
|
||||
file-rename-pattern "S2 " "episode-" { --exec | -e }
|
||||
|
||||
--dry-run is on by default.
|
||||
";
|
||||
}
|
||||
|
||||
if [[ $# < 2 || $# > 3 ]]; then
|
||||
help
|
||||
fi
|
||||
|
||||
PATTERN=$1
|
||||
REPLACE=$2
|
||||
|
||||
if [[ $# == 2 || ($# == 3 && ($3 == "--dry-run" || $3 == "-d" )) ]]; then
|
||||
for f in *$PATTERN*; do echo mv -i -- "$f" "${f//$PATTERN/$REPLACE}"; done
|
||||
elif [[ $# == 3 && ($3 == "--exec" || $3 == "-e" ) ]]; then
|
||||
for f in *$PATTERN*; do mv -i -- "$f" "${f//$PATTERN/$REPLACE}"; done
|
||||
fi
|
||||
|
||||
@@ -1,278 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
name_executable() {
|
||||
read "?The current name of the executable is $1. Do you want to change it? (y/N)" CHOICE
|
||||
|
||||
if [[ $CHOICE == "y" || $CHOICE == "Y" ]]; then
|
||||
read "?Enter the name of the executable: " NAME
|
||||
echo $NAME
|
||||
else
|
||||
echo $1
|
||||
fi
|
||||
}
|
||||
|
||||
save_desktop_entry() {
|
||||
if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
||||
NAME=$1
|
||||
EXECUTABLE=$2
|
||||
|
||||
echo "Creating a desktop entry for the $NAME project...\n"
|
||||
|
||||
# Create the desktop entry
|
||||
sudo echo "[Desktop Entry]" > /usr/share/applications/$NAME.desktop
|
||||
sudo echo "Name=$NAME" >> /usr/share/applications/$NAME.desktop
|
||||
sudo echo "Exec=$EXECUTABLE" >> /usr/share/applications/$NAME.desktop
|
||||
sudo echo "Type=Application" >> /usr/share/applications/$NAME.desktop
|
||||
sudo echo "# Auto-generated by the install script" >> /usr/share/applications/$NAME.desktop
|
||||
else
|
||||
echo "This operating system is not yet supported."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
help() {
|
||||
echo "This script installs a project onto the user's system."
|
||||
echo "Usage: install"
|
||||
echo " install <path-to-project>"
|
||||
echo " install -h | --help"
|
||||
echo "\nIf no path is provided, the script will look for a dependencies.txt file in the current directory."
|
||||
exit 0
|
||||
}
|
||||
|
||||
error_missing_dependencies() {
|
||||
echo "The dependencies.txt file is missing from the project directory."
|
||||
echo "This file should contain the required packages for the project to run."
|
||||
echo "The format should be as follows: <command>,<package>"
|
||||
echo "For example: python,python3"
|
||||
echo "Please create this file before continuing."
|
||||
echo "You can find an example file in the root directory of this project."
|
||||
exit 1
|
||||
}
|
||||
|
||||
success() {
|
||||
NAME=$1
|
||||
EXECUTABLE=$2
|
||||
|
||||
echo "The $NAME project and it's dependencies have been successfully installed onto your system."
|
||||
echo "You can now run the project by typing $EXECUTABLE into the terminal."
|
||||
|
||||
read "?Would you like to create a desktop entry for the $NAME project? (y/N): " CHOICE
|
||||
|
||||
if [[ $CHOICE == "y" || $CHOICE == "Y" ]]; then
|
||||
save_desktop_entry $NAME $EXECUTABLE
|
||||
fi
|
||||
}
|
||||
|
||||
install_c() {
|
||||
NAME=$1
|
||||
echo "\nOther languages and build systems are not yet supported."
|
||||
|
||||
exit 0
|
||||
}
|
||||
|
||||
install_python() {
|
||||
NAME=$1
|
||||
EXECUTABLE=$(name_executable $1)
|
||||
|
||||
# Get the current working directory and the virtual environment
|
||||
CWD=$(pwd)
|
||||
ENV=$(pwd)/bin/activate
|
||||
COMMAND="python $CWD/src/$NAME.py"
|
||||
|
||||
# Create the virtual environment
|
||||
python -m venv .
|
||||
source bin/activate
|
||||
|
||||
# Install Python packages in the virtual environment
|
||||
if [[ -f requirements.txt ]]; then
|
||||
pip install -r requirements.txt
|
||||
fi
|
||||
|
||||
|
||||
# Create the executable
|
||||
sudo echo "#!/bin/zsh" > /usr/local/bin/$EXECUTABLE
|
||||
sudo echo "source $ENV" >> /usr/local/bin/$EXECUTABLE
|
||||
sudo echo "$COMMAND" >> /usr/local/bin/$EXECUTABLE
|
||||
sudo echo "# Auto-generated by the install script" >> /usr/local/bin/$EXECUTABLE
|
||||
sudo chmod +x /usr/local/bin/$EXECUTABLE
|
||||
|
||||
success "$NAME" "$EXECUTABLE"
|
||||
}
|
||||
|
||||
install_java() {
|
||||
NAME=$1
|
||||
echo "Other languages and build systems are not yet supported."
|
||||
|
||||
exit 0
|
||||
}
|
||||
|
||||
install_other() {
|
||||
NAME=$1
|
||||
echo "Other languages and build systems are not yet supported."
|
||||
|
||||
exit 0
|
||||
}
|
||||
|
||||
install() {
|
||||
PROJECT_NAME=$1
|
||||
|
||||
echo "\nInstalling the $PROJECT_NAME project onto your system..."
|
||||
|
||||
echo "Please select the project language or build system:"
|
||||
echo "1. C"
|
||||
echo "2. Python"
|
||||
echo "3. Java"
|
||||
echo "4. Other"
|
||||
|
||||
read "?Enter the number of the project type: " PROJECT_TYPE
|
||||
|
||||
case $PROJECT_TYPE in
|
||||
1)
|
||||
install_c "$PROJECT_NAME"
|
||||
;;
|
||||
2)
|
||||
install_python "$PROJECT_NAME"
|
||||
;;
|
||||
3)
|
||||
install_java "$PROJECT_NAME"
|
||||
;;
|
||||
4)
|
||||
install_other "$PROJECT_NAME"
|
||||
;;
|
||||
*)
|
||||
echo "Invalid option"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
install_dependencies() {
|
||||
echo "Checking for required packages..."
|
||||
|
||||
# Check if the check-dependency command is installed
|
||||
if ! command -v check-dependency &> /dev/null
|
||||
then
|
||||
echo "The command check-dependency could not be found. Please install it before continuing."
|
||||
echo "You can find it at https://github.com/quaxlyqueen/scripts."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Iterate through each line of the dependencies.txt file
|
||||
# and check if the package is installed with check-dependency <command> <package>
|
||||
while read -r line; do
|
||||
command=$(echo $line | awk -F ',' '{print $1}')
|
||||
package=$(echo $line | awk -F ',' '{print $2}')
|
||||
|
||||
check-dependency $command $package
|
||||
|
||||
# If the package could not be installed, exit the script
|
||||
if [[ $? -eq 1 ]]; then
|
||||
echo "The command $command from package $package could not be installed. Please install it manually before continuing."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
done < dependencies.txt
|
||||
}
|
||||
|
||||
check_sudo() {
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as root"
|
||||
echo "Try 'sudo ./install'"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_theme() {
|
||||
USER=$SUDO_USER
|
||||
if [ ! -d /home/$USER/.config ];
|
||||
then
|
||||
echo "Creating the ~/.config directory..."
|
||||
su $USER -c "mkdir /home/$USER/.config"
|
||||
fi
|
||||
|
||||
if [ ! -d /home/$USER/.config/theme ];
|
||||
then
|
||||
echo "Creating the /home/$USER/.config/theme directory..."
|
||||
su $USER -c "mkdir /home/$USER/.config/theme"
|
||||
fi
|
||||
|
||||
THEME_DIR=/home/$USER/.config/theme
|
||||
|
||||
if [ ! -f $THEME_DIR/active.theme ];
|
||||
then
|
||||
su $USER -c "touch $THEME_DIR/light.theme"
|
||||
echo "base=#C6CAED" > $THEME_DIR/light.theme
|
||||
echo "accent=#4D5382" >> $THEME_DIR/light.theme
|
||||
echo "hover=#262940" >> $THEME_DIR/light.theme
|
||||
|
||||
su $USER -c "touch $THEME_DIR/dark.theme"
|
||||
echo "base=#262940" > $THEME_DIR/dark.theme
|
||||
echo "accent=#4D5382" >> $THEME_DIR/dark.theme
|
||||
echo "hover=#C6CAED" >> $THEME_DIR/dark.theme
|
||||
|
||||
su $USER -c "ln -s $THEME_DIR/dark.theme $THEME_DIR/active.theme"
|
||||
fi
|
||||
}
|
||||
|
||||
install-extra() {
|
||||
if [ -f "install-extra" ]; then
|
||||
echo "Running install-extra..."
|
||||
./install-extra
|
||||
fi
|
||||
}
|
||||
|
||||
check_args() {
|
||||
check_sudo
|
||||
check_theme
|
||||
|
||||
if [[ $# -gt 1 ]]; then
|
||||
echo "ERROR: There were too many arguments.\n"
|
||||
echo "Usage: install"
|
||||
echo " install <path-to-project>"
|
||||
echo " install -h | --help"
|
||||
exit 1
|
||||
|
||||
# No arguments provided
|
||||
elif [[ $# -eq 0 ]]; then
|
||||
|
||||
# Check if the current directory contains the required dependencies.txt file.
|
||||
if [[ ! -f dependencies.txt ]]; then
|
||||
error_missing_dependencies
|
||||
|
||||
# Install the project
|
||||
else
|
||||
PROJECT_NAME=$(pwd | cut -d '/' -f5)
|
||||
install_dependencies
|
||||
install "$PROJECT_NAME"
|
||||
install-extra
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# User argument provided
|
||||
else
|
||||
|
||||
# Display help message
|
||||
if [[ $1 == "-h" || $1 == "--help" ]]; then
|
||||
help
|
||||
fi
|
||||
|
||||
# Check if the specified directory exists
|
||||
if [[ ! -d $1 ]]; then
|
||||
echo "The specified project directory does not exist"
|
||||
exit 1
|
||||
|
||||
# Check if the specified directory contains the required dependencies.txt file.
|
||||
elif [[ ! -f $1/dependencies.txt ]]; then
|
||||
error_missing_dependencies
|
||||
|
||||
# Install the project
|
||||
else
|
||||
PROJECT_NAME=$1
|
||||
install_dependencies
|
||||
cd $PROJECT_NAME
|
||||
install-extra
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
check_args $1
|
||||
@@ -1,165 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
help() {
|
||||
echo "This script installs and sets up the configuration for the repo quaxlyqueen/scripts."
|
||||
echo "It will install the scripts in /usr/local/bin and set up the environment variables and aliases."
|
||||
echo "The user will be prompted to:"
|
||||
echo " - Set up the environment variables and aliases"
|
||||
echo " - Create a theme for supported applications"
|
||||
echo " - Set up Git, github-cli (gh), and gclone"
|
||||
|
||||
echo "\nUsage: sudo ./install"
|
||||
echo " sudo ./install -h | --help"
|
||||
exit 0
|
||||
}
|
||||
|
||||
# The script must be run as root
|
||||
is_root() {
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as root."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
create_theme() {
|
||||
USER=$1
|
||||
su $USER -c "mkdir /home/$USER/.config/theme"
|
||||
|
||||
echo "\nTheming currently supports .theme files with 3 colors: base, accent, and hover."
|
||||
echo "These themes can be changed at anytime by editing the .theme file in ~/.config/theme."
|
||||
echo "Supported applications will automatically use the active.theme link to theme themselves."
|
||||
echo "active.theme is a symbolic link to (for eg.) light.theme or dark.theme."
|
||||
|
||||
echo "\nMany themes can be created with this format, and using the 'set-theme <theme>' command."
|
||||
echo "See 'set-theme --help' for more information."
|
||||
|
||||
echo "\n\nYou can create a theme now or use the default light and dark themes."
|
||||
read "?Do you want to create a theme now? (y/n) " CHOICE
|
||||
|
||||
USER=$SUDO_USER
|
||||
DIR="/home/$USER/.config/theme"
|
||||
|
||||
if [[ $CHOICE == "y" ]]; then
|
||||
echo "\n"
|
||||
read "?Please enter the base color in hex format (e.g. #ffffff): " BASE
|
||||
read "?Please enter the accent color in hex format (e.g. #ffffff): " ACCENT
|
||||
read "?Please enter the hover color in hex format (e.g. #ffffff): " HOVER
|
||||
read "?Please enter the name of the theme: " NAME
|
||||
|
||||
su $USER -c "echo 'base=$BASE' > $DIR/$NAME.theme"
|
||||
su $USER -c "echo 'accent=$ACCENT' >> $DIR/$NAME.theme"
|
||||
su $USER -c "echo 'hover=$HOVER' >> $DIR/$NAME.theme"
|
||||
|
||||
echo "Theme created successfully."
|
||||
echo "You can now use the 'set-theme $NAME' command to use this theme."
|
||||
echo "Setting the active theme to $NAME.theme..."
|
||||
su $USER -c "ln -s $DIR/$NAME.theme $DIR/active.theme"
|
||||
|
||||
else
|
||||
echo "Creating default light and dark themes..."
|
||||
su $USER -c "echo 'base=#C6CAED' > $DIR/light.theme"
|
||||
su $USER -c "echo 'accent=#4D5382' >> $DIR/light.theme"
|
||||
su $USER -c "echo 'hover=#262940' >> $DIR/light.theme"
|
||||
|
||||
su $USER -c "echo 'base=#262940' > $DIR/dark.theme"
|
||||
su $USER -c "echo 'accent=#4D5382' >> $DIR/dark.theme"
|
||||
su $USER -c "echo 'hover=#C6CAED' >> $DIR/dark.theme"
|
||||
|
||||
read "?Do you want to set the active theme to the dark theme? (y/n) " CHOICE
|
||||
|
||||
if [[ $CHOICE == "y" ]]; then
|
||||
echo "Setting the active theme to dark.theme..."
|
||||
su $USER -c "ln -s $DIR/dark.theme $DIR/active.theme"
|
||||
else
|
||||
echo "Setting the active theme to light.theme..."
|
||||
su $USER -c "ln -s $DIR/light.theme $DIR/active.theme"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
setup_git() {
|
||||
# Set up gclone
|
||||
if [ ! -d "/home/$USER/.config/gclone" ]; then
|
||||
su $USER -c "mkdir /home/$USER/.config/gclone"
|
||||
su $USER -c "touch /home/$USER/.config/gclone/gclone.conf"
|
||||
|
||||
read "?Please enter your GitHub user name for gclone: " GHUSER
|
||||
su $USER -c "gclone --set-default $GHUSER"
|
||||
fi
|
||||
|
||||
# If the user has not set up git, do so now
|
||||
if [ ! -f "/home/$USER/.gitconfig" ]; then
|
||||
read "?Please enter your name for Git: " NAME
|
||||
read "?Please enter your email for Git: " EMAIL
|
||||
|
||||
su $USER -c "git config --global user.name $NAME"
|
||||
su $USER -c "git config --global user.email $EMAIL"
|
||||
fi
|
||||
|
||||
# Install github-cli if it is not already installed
|
||||
check_dependency "gh" "github-cli"
|
||||
|
||||
# If the user has not set up github-cli, do so now
|
||||
if [ ! -f "/home/$USER/.config/gh/hosts.yml" ]; then
|
||||
echo "Please log in to GitHub using github-cli."
|
||||
echo "This will allow you to modify your repositories and other GitHub features."
|
||||
|
||||
su $USER -c "gh auth login"
|
||||
fi
|
||||
}
|
||||
|
||||
# Create environment variables and global aliases
|
||||
setup_environment() {
|
||||
echo "Setting up the environment..."
|
||||
read "?By default, the scripts will install in the /usr/local/bin directory. Is this OK? (y/n): " CHOICE
|
||||
|
||||
if [[ $CHOICE == "n" ]]; then
|
||||
read "?Please enter the directory to install the scripts: " DIR
|
||||
else
|
||||
DIR="/usr/local/bin"
|
||||
fi
|
||||
|
||||
echo "# Auto-generated by quaxlyqueen/scripts. Environment setup" >> ~/.zshrc
|
||||
echo "alias gt='. goto $1'" >> ~/.zshrc
|
||||
echo "alias goto='. goto $1'" >> ~/.zshrc
|
||||
echo "export PATH=\$PATH:$DIR" >> ~/.zshrc
|
||||
|
||||
# Source the .zshrc file to update the environment
|
||||
source ~/.zshrc
|
||||
|
||||
USER=$SUDO_USER
|
||||
if [ ! -d "/home/$USER/.config" ]; then
|
||||
su $USER -c "mkdir /home/$USER/.config"
|
||||
create_theme $USER
|
||||
fi
|
||||
|
||||
if [ ! -d "/home/$USER/.config/theme" ]; then
|
||||
create_theme $USER
|
||||
fi
|
||||
|
||||
setup_git
|
||||
}
|
||||
|
||||
is_root
|
||||
if [[ $# -eq 1 ]]; then
|
||||
if [[ $1 == "-h" || $1 == "--help" ]]; then
|
||||
help
|
||||
fi
|
||||
fi
|
||||
|
||||
more_install
|
||||
if [ -f "install-extra" ]; then
|
||||
echo "Running install-extra..."
|
||||
sudo ./install-extra
|
||||
fi
|
||||
|
||||
# Install the scripts
|
||||
echo "Installing scripts..."
|
||||
sudo cp * /usr/local/bin
|
||||
setup_environment
|
||||
more_install
|
||||
|
||||
echo "Installation complete. Please restart your terminal to use the new commands, or run 'source ~/.zshrc'."
|
||||
echo "To remove the scripts, simply delete the files in /usr/local/bin and remove the aliases from your .zshrc file."
|
||||
echo "Thank you for using quaxlyqueen/scripts!"
|
||||
exit 0
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
TARGET=$1
|
||||
|
||||
if [[ -e $TARGET.mkv ]]; then
|
||||
ffmpeg -i $TARGET.mkv -n $TARGET.mp3
|
||||
rm $TARGET.mkv
|
||||
elif [[ -e $TARGET.webm ]]; then
|
||||
ffmpeg -i $TARGET.webm -n $TARGET.mp3
|
||||
rm $TARGET.webm
|
||||
elif [[ -e $TARGET.mp4 ]]; then
|
||||
ffmpeg -i $TARGET.mp4 -n $TARGET.mp3
|
||||
rm $TARGET.mp4
|
||||
else
|
||||
echo "file not found"
|
||||
fi
|
||||
+8
-17
@@ -11,14 +11,12 @@
|
||||
TYPES=("c", "rust", "c-sharp", "aspnet", "java", "js", "t3", "python", "flutter", "go", "php")
|
||||
|
||||
# Catch case where there are too many arguments.
|
||||
if [[ $# -gt 3 ]]; then
|
||||
if [[ $# -gt 2 ]]; then
|
||||
echo "Improper usage. Try:"
|
||||
echo "\nnewproject { language } { projectname } { -g | --git-project }"
|
||||
echo "\nnewproject { language } { projectname }"
|
||||
echo " newproject"
|
||||
echo " newproject c"
|
||||
echo " newproject c app"
|
||||
echo " newproject c app -g"
|
||||
echo " newproject c app --git-project"
|
||||
echo " newproject -h"
|
||||
echo " newproject --help\n"
|
||||
|
||||
@@ -35,12 +33,10 @@ elif [[ $1 == "-h" || $1 == "--help" ]]; then
|
||||
echo "Bookmarks the new project directory using the 'mark' script."
|
||||
echo "Detects required tools to use based upon language selected.\n"
|
||||
echo "Usage:"
|
||||
echo "\nnewproject { language } { projectname } { -g | --git-project }"
|
||||
echo "\nnewproject { language } { projectname }"
|
||||
echo " newproject"
|
||||
echo " newproject c"
|
||||
echo " newproject c app"
|
||||
echo " newproject c app -g"
|
||||
echo " newproject c app --git-project"
|
||||
echo " newproject -h"
|
||||
echo " newproject --help\n"
|
||||
|
||||
@@ -51,25 +47,16 @@ elif [[ $1 == "-h" || $1 == "--help" ]]; then
|
||||
elif [[ $# -eq 0 ]]; then
|
||||
read "?Language: " LANG
|
||||
read "?Project name: " NAME
|
||||
read "?Git project (y/N): " GIT
|
||||
|
||||
# User provides the project's language.
|
||||
elif [[ $# -eq 1 ]]; then
|
||||
LANG=$1
|
||||
read "?Project name: " NAME
|
||||
read "?Git project (y/N): " GIT
|
||||
|
||||
# User provides arguments for the language and project name.
|
||||
elif [[ $# -eq 2 ]]; then
|
||||
LANG=$1
|
||||
NAME=$2
|
||||
read "?Git project (y/N): " GIT
|
||||
|
||||
# User provides arguments for all fields.
|
||||
elif [[ $# -eq 3 ]]; then
|
||||
LANG=$1
|
||||
NAME=$2
|
||||
GIT=$3
|
||||
fi
|
||||
|
||||
# Check if the language the user has provided is supported.
|
||||
@@ -177,13 +164,17 @@ elif [[ $LANG == "react" ]]; then
|
||||
elif [[ $LANG == "php" ]]; then
|
||||
cp -r ~/templates/web/php/ $NAME
|
||||
cd $NAME
|
||||
read "?Use Composer (y/N): " COMPOSER
|
||||
if [[ $COMPOSER == "y" ]]; then
|
||||
composer init
|
||||
fi
|
||||
|
||||
mark
|
||||
|
||||
fi
|
||||
|
||||
read "?Git project (y/N): " GIT
|
||||
# If the user indicated the project will be a Git project, then run the ginit script.
|
||||
if [[ $GIT == "-g" || $GIT == "--git-project" ]]; then
|
||||
if [[ $GIT == "y" || $GIT == "Y" ]]; then
|
||||
ginit;
|
||||
fi
|
||||
|
||||
@@ -1,162 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
# Supported languages.
|
||||
TYPES=("c", "rs", "cs", "java", "js", "python", "flutter", "gradle", "go")
|
||||
|
||||
# Catch case where there are too many arguments.
|
||||
if [[ $# -gt 1 ]]; then
|
||||
echo "Proper usage: run {file}"
|
||||
echo " eg. run"
|
||||
echo " eg. run main"
|
||||
echo " eg. run gradle"
|
||||
echo " eg. run flutter"
|
||||
echo " eg. run -h"
|
||||
echo " eg. run --help"
|
||||
|
||||
exit
|
||||
|
||||
# Help page
|
||||
elif [[ $1 == "-h" || $1 == "--help" ]]; then
|
||||
echo "\nAbstracting away command line tools to compile and run code for various languages and frameworks."
|
||||
echo "User can use with or without an argument file, the filetype is not needed."
|
||||
echo "With no arguments, 'run' will list available (and supported) files."
|
||||
echo "Additionally, 'run' prompts for and passes command line arguments for a program.\n"
|
||||
echo "Detects required tools to use based upon filetypes.\n"
|
||||
echo "Usage:"
|
||||
echo " run"
|
||||
echo " run [filename]"
|
||||
echo " eg. run main"
|
||||
echo " run gradle"
|
||||
echo " run flutter"
|
||||
echo " run -h"
|
||||
echo " run --help\n"
|
||||
echo "Supported languages: $TYPES"
|
||||
|
||||
exit
|
||||
|
||||
# Default state, with a reminder of what files may be launched from based upon the currently supported languages.
|
||||
elif [[ $# -eq 0 ]]; then
|
||||
|
||||
echo "Files that may be launched from:"
|
||||
|
||||
# List files available to launch from.
|
||||
for f in *
|
||||
do
|
||||
TYPE=`echo $f | cut -d "." -f 2`
|
||||
counter=0
|
||||
|
||||
# Only list supported filetypes.
|
||||
if [[ ${TYPES[@]} =~ $TYPE ]]; then
|
||||
counter=$((counter+1)) # Increment counter to indicate the number of results.
|
||||
|
||||
# Format: filename (file type)
|
||||
echo `echo $f | cut -d "." -f 1` "("$TYPE")"
|
||||
fi
|
||||
done
|
||||
echo $counter" available files.\n"
|
||||
|
||||
# Catch case where there are no available files to run and exit.
|
||||
if [[ $counter -eq 0 ]]; then
|
||||
echo "No available files to run. Exiting."
|
||||
exit
|
||||
fi
|
||||
|
||||
read "?Which file would you like to launch from: " TMP
|
||||
|
||||
# Locate file and assign variables associated with the file (name and filetype).
|
||||
for f in *
|
||||
do
|
||||
FILE=`echo $f | cut -d "." -f 1`
|
||||
if [[ $FILE == $TMP ]]; then
|
||||
NAME=$TMP
|
||||
TYPE=`echo $f | cut -d "." -f 2`
|
||||
fi
|
||||
done
|
||||
|
||||
# User has provided the file name.
|
||||
elif [[ $# -eq 1 ]]; then
|
||||
|
||||
# Locate file and assign variables associated with the file (name and filetype).
|
||||
for f in *
|
||||
do
|
||||
FILE=`echo $f | cut -d "." -f 1`
|
||||
if [[ $FILE == $1 ]]; then
|
||||
NAME=$FILE
|
||||
TYPE=`echo $f | cut -d "." -f 2`
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
read "?Arguments: " ARGS
|
||||
|
||||
# Run C app.
|
||||
if [[ $TYPE == "c" ]]; then
|
||||
clear
|
||||
echo "Compiling..."
|
||||
gcc $NAME.c -lm
|
||||
echo "Output..."
|
||||
./a.out $ARGS
|
||||
|
||||
rm a.out
|
||||
|
||||
# Run a Rust app.
|
||||
elif [[ $TYPE == "rs" ]]; then
|
||||
clear
|
||||
cargo run
|
||||
|
||||
# Run C# app.
|
||||
elif [[ $TYPE == "cs" ]]; then
|
||||
clear
|
||||
echo "Compiling..."
|
||||
mcs -out:$NAME.exe $NAME.cs
|
||||
echo "Output..."
|
||||
mono $NAME.exe
|
||||
|
||||
# Run Java app.
|
||||
elif [[ $TYPE == "java" ]]; then
|
||||
clear
|
||||
echo "Compiling..."
|
||||
javac *.java
|
||||
echo "Output...";
|
||||
java $NAME $ARGS
|
||||
rm *.class
|
||||
|
||||
# Run JavaScript app.
|
||||
elif [[ $TYPE == "js" ]]; then
|
||||
clear
|
||||
echo "Output..."
|
||||
node $NAME.js
|
||||
|
||||
# Run Python app.
|
||||
elif [[ $TYPE == "py" ]]; then
|
||||
clear
|
||||
echo "Running..."
|
||||
python $FILE.py
|
||||
|
||||
# Run Golang app.
|
||||
elif [[ $TYPE == "go" ]]; then
|
||||
clear
|
||||
echo "Compiling..."
|
||||
go build
|
||||
echo "Output..."
|
||||
./discordo #TODO: need to dynamically obtain the newly created object file to run and then delete
|
||||
rm discordo
|
||||
|
||||
# Run app through Gradle
|
||||
elif [[ $1 == "gradle" ]]; then
|
||||
clear;
|
||||
echo "Output..."
|
||||
./gradlew run
|
||||
|
||||
# Run app through Flutter
|
||||
elif [[ $1 == "flutter" ]]; then
|
||||
clear;
|
||||
echo "Output..."
|
||||
flutter run
|
||||
|
||||
else
|
||||
read "?Language is not supported. Create a GH issue (y/n, default y): " GH
|
||||
if [[ $GH == "y" || $GH == "" ]]; then
|
||||
echo "Need to implement issue reporting."
|
||||
fi
|
||||
fi
|
||||
@@ -1,101 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
# This script is used to apply a theme to i3
|
||||
# It takes zero or one argument, the name of the theme to apply or toggle between light and dark
|
||||
# The theme must be located in $THEME_DIR
|
||||
# The theme must be a file with the extension .theme
|
||||
# The theme must be formatted as follows:
|
||||
# base=base_color
|
||||
# accent=accent_color
|
||||
# hover=hover_color
|
||||
# Where base_color, accent_color, and hover_color are hex values
|
||||
# The theme will be applied to i3, i3blocks, and rofi
|
||||
|
||||
cd ~/.config/theme
|
||||
CURRENT_THEME=`stat active.theme | grep .theme | cut -d " " -f 6 | awk -F '/' '{print $NF}'`
|
||||
|
||||
get_current_theme() {
|
||||
if [ -f active.theme ]; then
|
||||
CURRENT_THEME=`stat active.theme | grep .theme | cut -d " " -f 6 | awk -F '/' '{print $NF}'`
|
||||
else
|
||||
ln -sf dark.theme active.theme
|
||||
fi
|
||||
}
|
||||
|
||||
set_theme() {
|
||||
get_current_theme
|
||||
# Get the theme
|
||||
theme=$(cat active.theme)
|
||||
|
||||
# Apply the theme
|
||||
base=$(echo $theme | grep -oP '(?<=base=).*')
|
||||
accent=$(echo $theme | grep -oP '(?<=accent=).*')
|
||||
hover=$(echo $theme | grep -oP '(?<=hover=).*')
|
||||
mode=$(echo $CURRENT_THEME | cut -d '.' -f 1)
|
||||
|
||||
# Set i3 themes
|
||||
sed -i "s/color=\(.*\)/color=$hover/g" ~/.config/i3blocks/i3blocks.conf
|
||||
sed -i "s/set \$base .*/set \$base $base/g" ~/.config/i3/config
|
||||
sed -i "s/set \$accent .*/set \$accent $accent/g" ~/.config/i3/config
|
||||
sed -i "s/set \$hover .*/set \$hover $hover/g" ~/.config/i3/config
|
||||
|
||||
# Apply active.theme to alacritty
|
||||
ALACRITTY=~/.config/alacritty
|
||||
sed -i "s/themes\/.*\.toml/themes\/$mode.toml/g" $ALACRITTY/alacritty.toml
|
||||
|
||||
# Apply active.theme to rofi
|
||||
ROFI_PATH=theme.rasi
|
||||
sed -i "s/base\: .*/base: $base\;/" $ROFI_PATH
|
||||
sed -i "s/accent\: .*/accent: $accent\;/" $ROFI_PATH
|
||||
sed -i "s/hover\: .*/hover: $hover\;/" $ROFI_PATH
|
||||
|
||||
# Set NeoVim theme
|
||||
NVIM_PATH=~/.config/nvim/after/plugin/colors.lua
|
||||
if [[ $mode == "light" ]]; then
|
||||
sed -i "s/photon/antiphoton/" $NVIM_PATH
|
||||
sed -i "s/guibg=#262940/guibg=#C6CAED/" $NVIM_PATH
|
||||
sed -i "s/fg='#C6CAED'/fg='#262940'/" $NVIM_PATH
|
||||
else
|
||||
sed -i "s/anti//" $NVIM_PATH
|
||||
sed -i "s/guibg=#C6CAED/guibg=#262940/" $NVIM_PATH
|
||||
sed -i "s/fg='#262940'/fg='#C6CAED'/" $NVIM_PATH
|
||||
fi
|
||||
|
||||
i3-msg restart
|
||||
}
|
||||
|
||||
# If no argument is given, toggle between light and dark
|
||||
if [ $# -eq 0 ]; then
|
||||
if [[ $CURRENT_THEME == "light.theme" ]]; then
|
||||
ln -sf dark.theme active.theme
|
||||
else
|
||||
ln -sf light.theme active.theme
|
||||
fi
|
||||
|
||||
set_theme
|
||||
|
||||
elif [ $# -gt 1 ]; then
|
||||
echo "Too many arguments"
|
||||
exit 1
|
||||
|
||||
else
|
||||
# Check if the theme exists
|
||||
if [ ! -f $1.theme ]; then
|
||||
echo "Theme $1 does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if the theme is already applied
|
||||
if [ -f active.theme ]; then
|
||||
if [[ $(cat active.theme) == $(cat $1.theme) ]]; then
|
||||
echo "Theme $1 is already applied"
|
||||
exit 1
|
||||
else
|
||||
ln -sf $1.theme active.theme
|
||||
fi
|
||||
else
|
||||
ln -sf $1.theme active.theme
|
||||
fi
|
||||
|
||||
set_theme
|
||||
fi
|
||||
@@ -1,7 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
mkdir dev docs downloads pictures school tmp;
|
||||
sudo pacman -S alacritty android-tools archlinux-keyring aspnet-runtime base blender bluebubbles-desktop-app code dart devhelp devhelp-docs dhcpcd discord docker dotnet-sdk dracut efibootmgr feh firefox flatpak fzf gcc git github-cli godot gradle i3-wm i3lock i3status intel-ucode iwd java-openjfx java-openjfx-doc java-openjfx-src jdk-openjdk jgrasp jre-openjdk keepassxc kubeadm kubectl libreoffice-fresh linux linux-firmware luarocks man-db man-pages maven mono nasm neofetch neovim nerd-fonts-complete-starship net-tools networkmanager network-manager-applet ninja nitrogen nmap npm nvidia obs-studio os-prober php picom pavucontrol pidgin python python-pip reflector rofi rust simplescreenrecorder sof-firmware starship steam sudo tar texinfo thunar tldr typescript unrar vi virtualbox vlc wavpack wget wireshark-cli wl-clipboard xob xorg yarn yay zoom zoxide zsh
|
||||
git clone https://github.com/quaxlyqueen/notes;
|
||||
git clone https://github.com/quaxlyqueen/templates;
|
||||
cd dev; git clone https://github.com/quaxlyqueen/scripts;
|
||||
@@ -1,52 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
# Define the location of the bookmarks file
|
||||
bookmarks_file="$HOME/.bookmarks"
|
||||
|
||||
# Function to display usage information
|
||||
help() {
|
||||
echo "\nQuickly navigate to saved bookmarks in the terminal.\n"
|
||||
echo "Usage:"
|
||||
echo " goto downloads"
|
||||
echo " goto school"
|
||||
echo " goto portfolio"
|
||||
echo " goto -h"
|
||||
echo " goto --help"
|
||||
}
|
||||
|
||||
# Function to validate and change directory
|
||||
validate_dir() {
|
||||
local target_dir="$1"
|
||||
|
||||
# Check if bookmarks file exists
|
||||
if ! test -f "$bookmarks_file"; then
|
||||
echo "Error accessing bookmarks file: $bookmarks_file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Read each line in the bookmarks file
|
||||
while IFS= read -r line; do
|
||||
# Check if the line contains the target directory
|
||||
if [[ $line == *$target_dir* ]]; then
|
||||
# Change directory and exit
|
||||
cd "$line"
|
||||
return 0
|
||||
fi
|
||||
done < "$bookmarks_file"
|
||||
|
||||
# Target directory not found in bookmarks
|
||||
echo "Directory '$target_dir' not found in bookmarks."
|
||||
return 1
|
||||
}
|
||||
|
||||
# Check for valid number of arguments
|
||||
if [[ $# -ne 1 ]]; then
|
||||
echo "Invalid usage. See 'goto --help' for details."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Validate and change directory based on argument
|
||||
validate_dir "$1"
|
||||
|
||||
# Exit script (should be reached after successful directory change)
|
||||
exit 0
|
||||
-263
@@ -1,263 +0,0 @@
|
||||
goto: file format elf64-x86-64
|
||||
|
||||
|
||||
Disassembly of section .init:
|
||||
|
||||
0000000000001000 <_init>:
|
||||
1000: f3 0f 1e fa endbr64
|
||||
1004: 48 83 ec 08 sub $0x8,%rsp
|
||||
1008: 48 8b 05 c1 2f 00 00 mov 0x2fc1(%rip),%rax # 3fd0 <__gmon_start__@Base>
|
||||
100f: 48 85 c0 test %rax,%rax
|
||||
1012: 74 02 je 1016 <_init+0x16>
|
||||
1014: ff d0 call *%rax
|
||||
1016: 48 83 c4 08 add $0x8,%rsp
|
||||
101a: c3 ret
|
||||
|
||||
Disassembly of section .plt:
|
||||
|
||||
0000000000001020 <getenv@plt-0x10>:
|
||||
1020: ff 35 ca 2f 00 00 push 0x2fca(%rip) # 3ff0 <_GLOBAL_OFFSET_TABLE_+0x8>
|
||||
1026: ff 25 cc 2f 00 00 jmp *0x2fcc(%rip) # 3ff8 <_GLOBAL_OFFSET_TABLE_+0x10>
|
||||
102c: 0f 1f 40 00 nopl 0x0(%rax)
|
||||
|
||||
0000000000001030 <getenv@plt>:
|
||||
1030: ff 25 ca 2f 00 00 jmp *0x2fca(%rip) # 4000 <getenv@GLIBC_2.2.5>
|
||||
1036: 68 00 00 00 00 push $0x0
|
||||
103b: e9 e0 ff ff ff jmp 1020 <_init+0x20>
|
||||
|
||||
0000000000001040 <strlen@plt>:
|
||||
1040: ff 25 c2 2f 00 00 jmp *0x2fc2(%rip) # 4008 <strlen@GLIBC_2.2.5>
|
||||
1046: 68 01 00 00 00 push $0x1
|
||||
104b: e9 d0 ff ff ff jmp 1020 <_init+0x20>
|
||||
|
||||
0000000000001050 <chdir@plt>:
|
||||
1050: ff 25 ba 2f 00 00 jmp *0x2fba(%rip) # 4010 <chdir@GLIBC_2.2.5>
|
||||
1056: 68 02 00 00 00 push $0x2
|
||||
105b: e9 c0 ff ff ff jmp 1020 <_init+0x20>
|
||||
|
||||
0000000000001060 <__stack_chk_fail@plt>:
|
||||
1060: ff 25 b2 2f 00 00 jmp *0x2fb2(%rip) # 4018 <__stack_chk_fail@GLIBC_2.4>
|
||||
1066: 68 03 00 00 00 push $0x3
|
||||
106b: e9 b0 ff ff ff jmp 1020 <_init+0x20>
|
||||
|
||||
0000000000001070 <printf@plt>:
|
||||
1070: ff 25 aa 2f 00 00 jmp *0x2faa(%rip) # 4020 <printf@GLIBC_2.2.5>
|
||||
1076: 68 04 00 00 00 push $0x4
|
||||
107b: e9 a0 ff ff ff jmp 1020 <_init+0x20>
|
||||
|
||||
0000000000001080 <getcwd@plt>:
|
||||
1080: ff 25 a2 2f 00 00 jmp *0x2fa2(%rip) # 4028 <getcwd@GLIBC_2.2.5>
|
||||
1086: 68 05 00 00 00 push $0x5
|
||||
108b: e9 90 ff ff ff jmp 1020 <_init+0x20>
|
||||
|
||||
0000000000001090 <strcmp@plt>:
|
||||
1090: ff 25 9a 2f 00 00 jmp *0x2f9a(%rip) # 4030 <strcmp@GLIBC_2.2.5>
|
||||
1096: 68 06 00 00 00 push $0x6
|
||||
109b: e9 80 ff ff ff jmp 1020 <_init+0x20>
|
||||
|
||||
00000000000010a0 <fopen@plt>:
|
||||
10a0: ff 25 92 2f 00 00 jmp *0x2f92(%rip) # 4038 <fopen@GLIBC_2.2.5>
|
||||
10a6: 68 07 00 00 00 push $0x7
|
||||
10ab: e9 70 ff ff ff jmp 1020 <_init+0x20>
|
||||
|
||||
00000000000010b0 <getline@plt>:
|
||||
10b0: ff 25 8a 2f 00 00 jmp *0x2f8a(%rip) # 4040 <getline@GLIBC_2.2.5>
|
||||
10b6: 68 08 00 00 00 push $0x8
|
||||
10bb: e9 60 ff ff ff jmp 1020 <_init+0x20>
|
||||
|
||||
00000000000010c0 <exit@plt>:
|
||||
10c0: ff 25 82 2f 00 00 jmp *0x2f82(%rip) # 4048 <exit@GLIBC_2.2.5>
|
||||
10c6: 68 09 00 00 00 push $0x9
|
||||
10cb: e9 50 ff ff ff jmp 1020 <_init+0x20>
|
||||
|
||||
00000000000010d0 <strstr@plt>:
|
||||
10d0: ff 25 7a 2f 00 00 jmp *0x2f7a(%rip) # 4050 <strstr@GLIBC_2.2.5>
|
||||
10d6: 68 0a 00 00 00 push $0xa
|
||||
10db: e9 40 ff ff ff jmp 1020 <_init+0x20>
|
||||
|
||||
Disassembly of section .text:
|
||||
|
||||
00000000000010e0 <_start>:
|
||||
10e0: f3 0f 1e fa endbr64
|
||||
10e4: 31 ed xor %ebp,%ebp
|
||||
10e6: 49 89 d1 mov %rdx,%r9
|
||||
10e9: 5e pop %rsi
|
||||
10ea: 48 89 e2 mov %rsp,%rdx
|
||||
10ed: 48 83 e4 f0 and $0xfffffffffffffff0,%rsp
|
||||
10f1: 50 push %rax
|
||||
10f2: 54 push %rsp
|
||||
10f3: 45 31 c0 xor %r8d,%r8d
|
||||
10f6: 31 c9 xor %ecx,%ecx
|
||||
10f8: 48 8d 3d 1d 02 00 00 lea 0x21d(%rip),%rdi # 131c <main>
|
||||
10ff: ff 15 bb 2e 00 00 call *0x2ebb(%rip) # 3fc0 <__libc_start_main@GLIBC_2.34>
|
||||
1105: f4 hlt
|
||||
1106: 66 2e 0f 1f 84 00 00 cs nopw 0x0(%rax,%rax,1)
|
||||
110d: 00 00 00
|
||||
1110: 48 8d 3d 51 2f 00 00 lea 0x2f51(%rip),%rdi # 4068 <__TMC_END__>
|
||||
1117: 48 8d 05 4a 2f 00 00 lea 0x2f4a(%rip),%rax # 4068 <__TMC_END__>
|
||||
111e: 48 39 f8 cmp %rdi,%rax
|
||||
1121: 74 15 je 1138 <_start+0x58>
|
||||
1123: 48 8b 05 9e 2e 00 00 mov 0x2e9e(%rip),%rax # 3fc8 <_ITM_deregisterTMCloneTable@Base>
|
||||
112a: 48 85 c0 test %rax,%rax
|
||||
112d: 74 09 je 1138 <_start+0x58>
|
||||
112f: ff e0 jmp *%rax
|
||||
1131: 0f 1f 80 00 00 00 00 nopl 0x0(%rax)
|
||||
1138: c3 ret
|
||||
1139: 0f 1f 80 00 00 00 00 nopl 0x0(%rax)
|
||||
1140: 48 8d 3d 21 2f 00 00 lea 0x2f21(%rip),%rdi # 4068 <__TMC_END__>
|
||||
1147: 48 8d 35 1a 2f 00 00 lea 0x2f1a(%rip),%rsi # 4068 <__TMC_END__>
|
||||
114e: 48 29 fe sub %rdi,%rsi
|
||||
1151: 48 89 f0 mov %rsi,%rax
|
||||
1154: 48 c1 ee 3f shr $0x3f,%rsi
|
||||
1158: 48 c1 f8 03 sar $0x3,%rax
|
||||
115c: 48 01 c6 add %rax,%rsi
|
||||
115f: 48 d1 fe sar $1,%rsi
|
||||
1162: 74 14 je 1178 <_start+0x98>
|
||||
1164: 48 8b 05 6d 2e 00 00 mov 0x2e6d(%rip),%rax # 3fd8 <_ITM_registerTMCloneTable@Base>
|
||||
116b: 48 85 c0 test %rax,%rax
|
||||
116e: 74 08 je 1178 <_start+0x98>
|
||||
1170: ff e0 jmp *%rax
|
||||
1172: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1)
|
||||
1178: c3 ret
|
||||
1179: 0f 1f 80 00 00 00 00 nopl 0x0(%rax)
|
||||
1180: f3 0f 1e fa endbr64
|
||||
1184: 80 3d dd 2e 00 00 00 cmpb $0x0,0x2edd(%rip) # 4068 <__TMC_END__>
|
||||
118b: 75 33 jne 11c0 <_start+0xe0>
|
||||
118d: 55 push %rbp
|
||||
118e: 48 83 3d 4a 2e 00 00 cmpq $0x0,0x2e4a(%rip) # 3fe0 <__cxa_finalize@GLIBC_2.2.5>
|
||||
1195: 00
|
||||
1196: 48 89 e5 mov %rsp,%rbp
|
||||
1199: 74 0d je 11a8 <_start+0xc8>
|
||||
119b: 48 8b 3d be 2e 00 00 mov 0x2ebe(%rip),%rdi # 4060 <__dso_handle>
|
||||
11a2: ff 15 38 2e 00 00 call *0x2e38(%rip) # 3fe0 <__cxa_finalize@GLIBC_2.2.5>
|
||||
11a8: e8 63 ff ff ff call 1110 <_start+0x30>
|
||||
11ad: c6 05 b4 2e 00 00 01 movb $0x1,0x2eb4(%rip) # 4068 <__TMC_END__>
|
||||
11b4: 5d pop %rbp
|
||||
11b5: c3 ret
|
||||
11b6: 66 2e 0f 1f 84 00 00 cs nopw 0x0(%rax,%rax,1)
|
||||
11bd: 00 00 00
|
||||
11c0: c3 ret
|
||||
11c1: 66 66 2e 0f 1f 84 00 data16 cs nopw 0x0(%rax,%rax,1)
|
||||
11c8: 00 00 00 00
|
||||
11cc: 0f 1f 40 00 nopl 0x0(%rax)
|
||||
11d0: f3 0f 1e fa endbr64
|
||||
11d4: e9 67 ff ff ff jmp 1140 <_start+0x60>
|
||||
|
||||
00000000000011d9 <validateDir>:
|
||||
11d9: 41 54 push %r12
|
||||
11db: 55 push %rbp
|
||||
11dc: 53 push %rbx
|
||||
11dd: 48 81 ec 20 10 00 00 sub $0x1020,%rsp
|
||||
11e4: 49 89 fc mov %rdi,%r12
|
||||
11e7: 64 48 8b 04 25 28 00 mov %fs:0x28,%rax
|
||||
11ee: 00 00
|
||||
11f0: 48 89 84 24 18 10 00 mov %rax,0x1018(%rsp)
|
||||
11f7: 00
|
||||
11f8: 31 c0 xor %eax,%eax
|
||||
11fa: 48 8d 3d 03 0e 00 00 lea 0xe03(%rip),%rdi # 2004 <_IO_stdin_used+0x4>
|
||||
1201: e8 2a fe ff ff call 1030 <getenv@plt>
|
||||
1206: 48 89 c3 mov %rax,%rbx
|
||||
1209: 48 89 c7 mov %rax,%rdi
|
||||
120c: e8 2f fe ff ff call 1040 <strlen@plt>
|
||||
1211: 48 01 d8 add %rbx,%rax
|
||||
1214: 48 b9 2f 2e 62 6f 6f movabs $0x616d6b6f6f622e2f,%rcx
|
||||
121b: 6b 6d 61
|
||||
121e: 48 89 08 mov %rcx,(%rax)
|
||||
1221: c7 40 08 72 6b 73 00 movl $0x736b72,0x8(%rax)
|
||||
1228: 48 8d 35 ea 0d 00 00 lea 0xdea(%rip),%rsi # 2019 <_IO_stdin_used+0x19>
|
||||
122f: 48 89 df mov %rbx,%rdi
|
||||
1232: e8 69 fe ff ff call 10a0 <fopen@plt>
|
||||
1237: 48 85 c0 test %rax,%rax
|
||||
123a: 0f 84 b9 00 00 00 je 12f9 <validateDir+0x120>
|
||||
1240: 48 89 c5 mov %rax,%rbp
|
||||
1243: 48 8d 7c 24 10 lea 0x10(%rsp),%rdi
|
||||
1248: be 00 10 00 00 mov $0x1000,%esi
|
||||
124d: e8 2e fe ff ff call 1080 <getcwd@plt>
|
||||
1252: 48 85 c0 test %rax,%rax
|
||||
1255: 74 16 je 126d <validateDir+0x94>
|
||||
1257: 48 8d 74 24 10 lea 0x10(%rsp),%rsi
|
||||
125c: 48 8d 3d a6 0d 00 00 lea 0xda6(%rip),%rdi # 2009 <_IO_stdin_used+0x9>
|
||||
1263: b8 00 00 00 00 mov $0x0,%eax
|
||||
1268: e8 03 fe ff ff call 1070 <printf@plt>
|
||||
126d: 48 c7 04 24 00 00 00 movq $0x0,(%rsp)
|
||||
1274: 00
|
||||
1275: 48 c7 44 24 08 00 00 movq $0x0,0x8(%rsp)
|
||||
127c: 00 00
|
||||
127e: 48 8d 74 24 08 lea 0x8(%rsp),%rsi
|
||||
1283: 48 89 e7 mov %rsp,%rdi
|
||||
1286: 48 89 ea mov %rbp,%rdx
|
||||
1289: e8 22 fe ff ff call 10b0 <getline@plt>
|
||||
128e: 48 83 f8 ff cmp $0xffffffffffffffff,%rax
|
||||
1292: 74 46 je 12da <validateDir+0x101>
|
||||
1294: 48 8b 34 24 mov (%rsp),%rsi
|
||||
1298: 48 8d 3d 73 0d 00 00 lea 0xd73(%rip),%rdi # 2012 <_IO_stdin_used+0x12>
|
||||
129f: b8 00 00 00 00 mov $0x0,%eax
|
||||
12a4: e8 c7 fd ff ff call 1070 <printf@plt>
|
||||
12a9: 48 8b 1c 24 mov (%rsp),%rbx
|
||||
12ad: 4c 89 e6 mov %r12,%rsi
|
||||
12b0: 48 89 df mov %rbx,%rdi
|
||||
12b3: e8 18 fe ff ff call 10d0 <strstr@plt>
|
||||
12b8: 48 85 c0 test %rax,%rax
|
||||
12bb: 74 c1 je 127e <validateDir+0xa5>
|
||||
12bd: 48 89 de mov %rbx,%rsi
|
||||
12c0: 48 8d 3d 4b 0d 00 00 lea 0xd4b(%rip),%rdi # 2012 <_IO_stdin_used+0x12>
|
||||
12c7: b8 00 00 00 00 mov $0x0,%eax
|
||||
12cc: e8 9f fd ff ff call 1070 <printf@plt>
|
||||
12d1: 48 8b 3c 24 mov (%rsp),%rdi
|
||||
12d5: e8 76 fd ff ff call 1050 <chdir@plt>
|
||||
12da: 48 8b 84 24 18 10 00 mov 0x1018(%rsp),%rax
|
||||
12e1: 00
|
||||
12e2: 64 48 2b 04 25 28 00 sub %fs:0x28,%rax
|
||||
12e9: 00 00
|
||||
12eb: 75 2a jne 1317 <validateDir+0x13e>
|
||||
12ed: 48 81 c4 20 10 00 00 add $0x1020,%rsp
|
||||
12f4: 5b pop %rbx
|
||||
12f5: 5d pop %rbp
|
||||
12f6: 41 5c pop %r12
|
||||
12f8: c3 ret
|
||||
12f9: 48 89 de mov %rbx,%rsi
|
||||
12fc: 48 8d 3d 25 0d 00 00 lea 0xd25(%rip),%rdi # 2028 <_IO_stdin_used+0x28>
|
||||
1303: b8 00 00 00 00 mov $0x0,%eax
|
||||
1308: e8 63 fd ff ff call 1070 <printf@plt>
|
||||
130d: bf 02 00 00 00 mov $0x2,%edi
|
||||
1312: e8 a9 fd ff ff call 10c0 <exit@plt>
|
||||
1317: e8 44 fd ff ff call 1060 <__stack_chk_fail@plt>
|
||||
|
||||
000000000000131c <main>:
|
||||
131c: 53 push %rbx
|
||||
131d: 83 ff 02 cmp $0x2,%edi
|
||||
1320: 75 42 jne 1364 <main+0x48>
|
||||
1322: 48 8b 5e 08 mov 0x8(%rsi),%rbx
|
||||
1326: 48 8d 35 ee 0c 00 00 lea 0xcee(%rip),%rsi # 201b <_IO_stdin_used+0x1b>
|
||||
132d: 48 89 df mov %rbx,%rdi
|
||||
1330: e8 5b fd ff ff call 1090 <strcmp@plt>
|
||||
1335: 85 c0 test %eax,%eax
|
||||
1337: 74 13 je 134c <main+0x30>
|
||||
1339: 48 8d 35 de 0c 00 00 lea 0xcde(%rip),%rsi # 201e <_IO_stdin_used+0x1e>
|
||||
1340: 48 89 df mov %rbx,%rdi
|
||||
1343: e8 48 fd ff ff call 1090 <strcmp@plt>
|
||||
1348: 85 c0 test %eax,%eax
|
||||
134a: 75 30 jne 137c <main+0x60>
|
||||
134c: 48 8d 3d cd 0c 00 00 lea 0xccd(%rip),%rdi # 2020 <_IO_stdin_used+0x20>
|
||||
1353: b8 00 00 00 00 mov $0x0,%eax
|
||||
1358: e8 13 fd ff ff call 1070 <printf@plt>
|
||||
135d: b8 00 00 00 00 mov $0x0,%eax
|
||||
1362: 5b pop %rbx
|
||||
1363: c3 ret
|
||||
1364: 48 8d 3d aa 0c 00 00 lea 0xcaa(%rip),%rdi # 2015 <_IO_stdin_used+0x15>
|
||||
136b: b8 00 00 00 00 mov $0x0,%eax
|
||||
1370: e8 fb fc ff ff call 1070 <printf@plt>
|
||||
1375: b8 01 00 00 00 mov $0x1,%eax
|
||||
137a: eb e6 jmp 1362 <main+0x46>
|
||||
137c: 48 89 df mov %rbx,%rdi
|
||||
137f: e8 55 fe ff ff call 11d9 <validateDir>
|
||||
1384: b8 00 00 00 00 mov $0x0,%eax
|
||||
1389: eb d7 jmp 1362 <main+0x46>
|
||||
|
||||
Disassembly of section .fini:
|
||||
|
||||
000000000000138c <_fini>:
|
||||
138c: f3 0f 1e fa endbr64
|
||||
1390: 48 83 ec 08 sub $0x8,%rsp
|
||||
1394: 48 83 c4 08 add $0x8,%rsp
|
||||
1398: c3 ret
|
||||
-73
@@ -1,73 +0,0 @@
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/*
|
||||
void error() {
|
||||
printf("\nImproper usage: goto[ keyword ]\n"
|
||||
" Usage:\n"
|
||||
" goto downloads\n"
|
||||
" goto school\n"
|
||||
" goto portfolio\n"
|
||||
" goto -h\n"
|
||||
" goto --help");
|
||||
}
|
||||
|
||||
void help() {
|
||||
printf("\nQuickly navigate to saved bookmarks in the terminal.\n"
|
||||
" Usage:\n"
|
||||
" goto downloads\n"
|
||||
" goto school\n"
|
||||
" goto portfolio\n"
|
||||
" goto -h\n"
|
||||
" goto --help");
|
||||
}
|
||||
*/
|
||||
|
||||
void validateDir(char input[]) {
|
||||
char *bookmarksFile = strcat(getenv("HOME"), "/.bookmarks");
|
||||
// char *bookmarksFile = "/home/jashton/.bookmarks";
|
||||
FILE *f = fopen(bookmarksFile, "r");
|
||||
// Unable to access file.
|
||||
if (f == NULL) {
|
||||
printf("Error accessing file located at %s.\n", bookmarksFile);
|
||||
exit(2);
|
||||
} else {
|
||||
char cwd[PATH_MAX];
|
||||
if (getcwd(cwd, sizeof(cwd)) != NULL) {
|
||||
printf("cwd: %s\n", cwd);
|
||||
}
|
||||
|
||||
char *line = NULL;
|
||||
size_t len = 0;
|
||||
ssize_t read;
|
||||
|
||||
while ((read = getline(&line, &len, f)) != -1) {
|
||||
printf("%s", line);
|
||||
if (strstr(line, input) != NULL) {
|
||||
printf("%s", line);
|
||||
chdir(line);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
// Invalid number of arguments.
|
||||
if (argc != 2) {
|
||||
// error();
|
||||
printf("error");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Display help.
|
||||
if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0)
|
||||
printf("help");
|
||||
else
|
||||
validateDir(argv[1]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
-89
@@ -1,89 +0,0 @@
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// Displays error message upon improper usage.
|
||||
void error() {
|
||||
printf("\nImproper usage: mark { -ls | -rm [ keyword(s) ] }\n"
|
||||
" Usage:\n"
|
||||
" mark\n"
|
||||
" mark -ls\n"
|
||||
" mark -rm [ keyword ]\n"
|
||||
" mark -h\n"
|
||||
" mark --help");
|
||||
}
|
||||
|
||||
// Displays help message.
|
||||
void help() {
|
||||
printf("\nCreate and manage persistent bookmarks in the terminal.\n"
|
||||
"Usage:\n"
|
||||
" mark\n"
|
||||
" mark -ls\n"
|
||||
" mark -rm [ keyword ]\n"
|
||||
" mark -h\n"
|
||||
" mark --help");
|
||||
}
|
||||
|
||||
// Lists all bookmarks in file.
|
||||
void list(FILE *f) {
|
||||
int c;
|
||||
printf("Bookmarks:\n");
|
||||
while (1) {
|
||||
c = fgetc(f);
|
||||
if (feof(f))
|
||||
break;
|
||||
printf("%c", c);
|
||||
}
|
||||
}
|
||||
|
||||
// Removes a bookmark from the file.
|
||||
void removeMark(FILE *f, char *argv[]) {
|
||||
printf("remove mark function not implemented. received input to remove: %s.",
|
||||
argv[2]); // TODO: Need to implement.
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
char *bookmarksFile = strcat(getenv("HOME"), "/.bookmarks");
|
||||
FILE *f = fopen(bookmarksFile, "a+");
|
||||
|
||||
// Unable to access file.
|
||||
if (f == NULL) {
|
||||
printf("Error accessing file located at %s.", bookmarksFile);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Invalid number of arguments.
|
||||
else if (argc > 2 && strcmp(argv[1], "-rm") != 0) {
|
||||
error();
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Append the current directory to the bookmarks file.
|
||||
else if (argc == 1) {
|
||||
char cwd[PATH_MAX];
|
||||
fprintf(f, "\n%s", getcwd(cwd, sizeof(cwd)));
|
||||
printf("Successfully bookmarked %s.", cwd);
|
||||
}
|
||||
|
||||
// Display help.
|
||||
else if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0)
|
||||
help();
|
||||
|
||||
// List bookmarks.
|
||||
else if (strcmp(argv[1], "-ls") == 0)
|
||||
list(f);
|
||||
|
||||
else if (strcmp(argv[1], "-rm") == 0)
|
||||
removeMark(f, argv);
|
||||
|
||||
// Invalid argument.
|
||||
else {
|
||||
error();
|
||||
return 1;
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
error() {
|
||||
echo "Improper usage. To increase a value in a file, update [target_file] {+, -}[change]."
|
||||
echo "For example, to increase the volume by 5, use 'update volume +5'."
|
||||
echo "To decrease the brightness by 10, use 'update brightness -10'."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Set up target file
|
||||
get_target() {
|
||||
TARGET=$1
|
||||
|
||||
if [[ $TARGET == "volume" ]]; then
|
||||
echo "/home/jashton/.config/xob/volume"
|
||||
|
||||
elif [[ $TARGET == "brightness" ]]; then
|
||||
echo "/home/jashton/.config/xob/brightness"
|
||||
|
||||
else
|
||||
echo "Invalid target. Please use 'volume' or 'brightness'."
|
||||
error
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Format change
|
||||
get_change() {
|
||||
CHANGE=$1
|
||||
|
||||
if [[ $CHANGE[1] == "+" ]]; then
|
||||
echo $CHANGE[2,-1]
|
||||
return ${CHANGE[2,-1]}
|
||||
elif [[ $CHANGE[1] == "-" ]]; then
|
||||
echo -$CHANGE[2,-1]
|
||||
return -${CHANGE[2,-1]}
|
||||
else
|
||||
echo "Invalid change. Please use '+' or '-'."
|
||||
error
|
||||
fi
|
||||
}
|
||||
|
||||
update() {
|
||||
CHANGE=$1
|
||||
TARGET=$2
|
||||
TARGET_FILE=$(get_target "$TARGET")
|
||||
|
||||
OLDNUM=`head $TARGET_FILE`
|
||||
NEWNUM=`expr $OLDNUM + $CHANGE`
|
||||
|
||||
if [[ $NEWNUM -le 100 && $NEWNUM -ge 0 ]]; then
|
||||
sed -i "s/$OLDNUM/$NEWNUM/g" $TARGET_FILE
|
||||
|
||||
if [[ $TARGET == "volume" ]]; then
|
||||
pamixer --set-volume $NEWNUM%
|
||||
|
||||
elif [[ $TARGET == "brightness" ]]; then
|
||||
brightnessctl set $NEWNUM%
|
||||
|
||||
else
|
||||
echo "Invalid target. Please use 'volume' or 'brightness'."
|
||||
error
|
||||
fi
|
||||
|
||||
echo $NEWNUM >> ~/.config/xob/xobpipe
|
||||
exit 0
|
||||
else
|
||||
echo "Invalid value. Please use a number between 0 and 100."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Check for proper number of arguments
|
||||
if [[ $# -ne 2 ]]; then
|
||||
error
|
||||
fi
|
||||
|
||||
TARGET=$1
|
||||
CHANGE=$(get_change "$2")
|
||||
|
||||
# Set up xob
|
||||
tail -f ~/.config/xob/xobpipe | xob -s $TARGET &
|
||||
|
||||
update "$CHANGE" "$TARGET" &
|
||||
@@ -1,22 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
tail -f ~/.config/xob/xobpipe | xob -s volume &
|
||||
if [[ $# -eq 2 ]]; then
|
||||
CHANGE=$1
|
||||
TARGET_FILE=$2
|
||||
elif [[ $# -eq 3 ]]; then
|
||||
CHANGE=`expr 0 - $2`
|
||||
TARGET_FILE=$3
|
||||
else
|
||||
echo "Improper usage. To increase a value in a file,\nupdate-bl [change] [target_file]."
|
||||
echo "To decrease a value in a file,\nupdate-bl --decrease [change] [target_file]."
|
||||
fi
|
||||
|
||||
OLDNUM=`cut -f1 $TARGET_FILE`
|
||||
NEWNUM=`expr $OLDNUM + $CHANGE`
|
||||
|
||||
if [[ $NEWNUM -le 100 && $NEWNUM -ge 0 ]]; then
|
||||
sed -i "s/$OLDNUM/$NEWNUM/g" $TARGET_FILE
|
||||
brightnessctl set $NEWNUM%
|
||||
echo $NEWNUM >> ~/.config/xob/xobpipe
|
||||
fi
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
tail -f ~/.config/xob/xobpipe | xob -s volume &
|
||||
if [[ $# -eq 2 ]]; then
|
||||
CHANGE=$1
|
||||
TARGET_FILE=$2
|
||||
elif [[ $# -eq 3 ]]; then
|
||||
CHANGE=`expr 0 - $2`
|
||||
TARGET_FILE=$3
|
||||
else
|
||||
echo "Improper usage. To increase a value in a file,\nupdate-val [change] [target_file]."
|
||||
echo "To decrease a value in a file,\nupdate-val --decrease [change] [target_file]."
|
||||
fi
|
||||
|
||||
OLDNUM=`cut -f1 $TARGET_FILE`
|
||||
NEWNUM=`expr $OLDNUM + $CHANGE`
|
||||
|
||||
if [[ $NEWNUM -le 100 && $NEWNUM -ge 0 ]]; then
|
||||
sed -i "s/$OLDNUM/$NEWNUM/g" $TARGET_FILE
|
||||
pactl set-sink-volume @DEFAULT_SINK@ $NEWNUM%
|
||||
echo $NEWNUM >> ~/.config/xob/xobpipe
|
||||
fi
|
||||
Reference in New Issue
Block a user