cleanup
This commit is contained in:
@@ -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
|
||||
-73
@@ -1,73 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.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);
|
||||
return;
|
||||
}
|
||||
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.
|
||||
else if(strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) printf("help");
|
||||
else validateDir(argv[1]);
|
||||
}
|
||||
-86
@@ -1,86 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.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,183 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
const int numTypes = 8;
|
||||
int type;
|
||||
char name[25];
|
||||
|
||||
const char *types[8];
|
||||
|
||||
int error() {
|
||||
printf("Improper usage. Try:");
|
||||
|
||||
printf("\n\nnewproject { language }");
|
||||
printf("\n newproject");
|
||||
printf("\n newproject c");
|
||||
printf("\n newproject -h");
|
||||
printf("\n newproject --help");
|
||||
|
||||
printf("\n\nSupported languages/stacks:");
|
||||
for(int i = 0; i < numTypes; i++) {
|
||||
printf("%s, ", types[i]);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int help() {
|
||||
printf("Abstracting away command line tools to create projects in various languages.");
|
||||
printf("\nUser can use with or without arguments. Without arguments, 'newproject' will");
|
||||
printf("\nprompt for a supported language, project name, and if a git repository should");
|
||||
printf("\nbe created.\n\nBookmarks the new project directory using the 'mark' script.");
|
||||
printf("\nDetects required tools to use based upon language selected.\n");
|
||||
printf("\n\nUsage:\nnewproject { language }");
|
||||
printf("\n newproject");
|
||||
printf("\n newproject c");
|
||||
printf("\n newproject -h");
|
||||
printf("\n newproject --help");
|
||||
|
||||
printf("\n\nSupported languages/stacks:");
|
||||
for(int i = 0; i < numTypes; i++) {
|
||||
printf("%s, ", types[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void getName() {
|
||||
printf("Project name: ");
|
||||
fgets(name, 25, stdin);
|
||||
}
|
||||
|
||||
int initC() {
|
||||
getName();
|
||||
mkdir(name, S_IRWXU);
|
||||
chdir(name);
|
||||
system("cp -r ~/templates/c/main.c");
|
||||
system("mark");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void initRust() {
|
||||
getName();
|
||||
char arduino[1];
|
||||
printf("Is this an Arduino project? (y/N): ");
|
||||
scanf("%s", arduino);
|
||||
|
||||
if(strcmp("y", arduino)) system("cargo generate --git https://github.com/Rahix/avr-hal-template.git");
|
||||
else if(strcmp("N", arduino) || strcmp("n", arduino)) {
|
||||
char cmd[15];
|
||||
strcpy(cmd, "cargo new ");
|
||||
strcat(cmd, name);
|
||||
|
||||
system(cmd);
|
||||
} else {
|
||||
printf("\nThe choice is y, N, or n. Please try again.");
|
||||
initRust();
|
||||
}
|
||||
}
|
||||
|
||||
void initCSharp() {
|
||||
getName();
|
||||
mkdir(name, S_IRWXU);
|
||||
chdir(name);
|
||||
system("mark");
|
||||
system("dotnet new console");
|
||||
}
|
||||
|
||||
void initJava() {
|
||||
getName();
|
||||
mkdir(name, S_IRWXU);
|
||||
chdir(name);
|
||||
system("mark");
|
||||
system("gradle init");
|
||||
}
|
||||
|
||||
void initHtml() {
|
||||
getName();
|
||||
mkdir(name, S_IRWXU);
|
||||
chdir(name);
|
||||
|
||||
system("cp -r ~/templates/web/public_html");
|
||||
chdir("public_html");
|
||||
system("mark");
|
||||
}
|
||||
|
||||
void initJs() {
|
||||
getName();
|
||||
mkdir(name, S_IRWXU);
|
||||
chdir(name);
|
||||
system("mark");
|
||||
system("touch main.js");
|
||||
}
|
||||
|
||||
void initPython() {
|
||||
getName();
|
||||
mkdir(name, S_IRWXU);
|
||||
chdir(name);
|
||||
system("touch main.py");
|
||||
system("mark");
|
||||
}
|
||||
|
||||
void initFlutter() {
|
||||
getName();
|
||||
char cmd[25];
|
||||
strcpy(cmd, "flutter create ");
|
||||
strcat(cmd, name);
|
||||
system(cmd);
|
||||
|
||||
chdir(name);
|
||||
system("mark");
|
||||
}
|
||||
|
||||
void initT3() {
|
||||
system("npm create t3-app@latest");
|
||||
}
|
||||
|
||||
void determineLang(char *argv[]) {
|
||||
printf("determining lang");
|
||||
if(strcmp(argv[1], types[0]) == 0) initC();
|
||||
else if(strcmp(argv[1], types[1]) == 0) initRust();
|
||||
else if(strcmp(argv[1], types[2]) == 0) initCSharp();
|
||||
else if(strcmp(argv[1], types[3]) == 0) initJava();
|
||||
else if(strcmp(argv[1], types[4]) == 0) initJs();
|
||||
else if(strcmp(argv[1], types[5]) == 0) initT3();
|
||||
else if(strcmp(argv[1], types[6]) == 0) initPython();
|
||||
else if(strcmp(argv[1], types[7]) == 0) initFlutter();
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
types[0] = "c";
|
||||
types[1] = "rust";
|
||||
types[2] = "c-sharp";
|
||||
types[3] = "java";
|
||||
types[4] = "js";
|
||||
types[5] = "t3";
|
||||
types[6] = "python";
|
||||
types[7] = "flutter";
|
||||
|
||||
switch (argc) {
|
||||
case 1:
|
||||
printf("Language: ");
|
||||
char *cmd[25];
|
||||
scanf("%s", *cmd);
|
||||
|
||||
determineLang(cmd);
|
||||
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if(strcmp(argv[1], "-h") == 0) return help();
|
||||
else if(strcmp(argv[1], "--help") == 0) return help();
|
||||
else determineLang(argv[1]);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
return error();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user