From 44ccbbfe6e4ce3e7b583a50a95c88b13faf9fd27 Mon Sep 17 00:00:00 2001 From: Pratik Tripathy Date: Thu, 8 Feb 2024 23:13:12 +0530 Subject: [PATCH] Initial Commit --- 10x_project_access.sh | 48 +++++++++++++++++++++++++++++++++++++++++++ Readme.md | 12 +++++++++++ 2 files changed, 60 insertions(+) create mode 100644 10x_project_access.sh create mode 100644 Readme.md diff --git a/10x_project_access.sh b/10x_project_access.sh new file mode 100644 index 0000000..174b04c --- /dev/null +++ b/10x_project_access.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +op() { + local chosen_project + chosen_project="$(find -L ~/Code -mindepth 2 -maxdepth 2 -not -path '*/.*' -printf "%T@ %p\n" | sort -nr | cut -d ' ' -f 2- | fzf --prompt='Select a project: ')" + + # Do nothing and return if user cancelled out + if [ -z "$chosen_project" ]; then + return 0 + fi + + cd "$chosen_project" || return + nvim +} + +pnew(){ + local directory + directory="$(find -L ~/Code/ -mindepth 1 -maxdepth 1 -not -path '*/.*' -type d | sed '/Squbix\|KeepWorks\|Supra/d' | sort | fzf --prompt='In which directory? ')" + + # Do nothing and return if user cancelled out + if [ -z "$directory" ]; then + return 0 + fi + + local project_name + if [ -n "$1" ]; then + project_name="$1" + else + project_name=$(find -L "$directory" -mindepth 1 -maxdepth 1 -not -path '*/.*' -type d | fzf --print-query -e +i --prompt='Project name (AVOID EXISTING ONES BELOW): ' | head -1) + fi + + if [ -z "$project_name" ]; then + echo "You did not chose a project name!!!" + return 1 + fi + + if [ -d "$directory/$project_name" ]; then + echo "$directory/$project_name project already exists" + echo "Try again" + return 1 + # TODO: Should allow to reenter the name + fi + + [ -d "$directory/$project_name" ] || mkdir -p "$directory/$project_name" || return + + cd "$directory/$project_name" || return + nvim +} diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..a28e399 --- /dev/null +++ b/Readme.md @@ -0,0 +1,12 @@ + +# Increase (My) Dev Productivity + +- A list of scripts to automate my daily development activities + +## Note to Self + +- Scripts should be symlinked to $XDG_CONFIG_HOME/shell/ directory +- ~/.profile should source everything inside $XDG_CONFIG_HOME/shell +- Keep them as portable as possible + 1. Across all *nic OS + 2. Across sh, bash, zsh