- Moved existing functions from dotfiles over to this repo.

- Made pnew() loop till a valid name is given.
- Made bootstrap script to symlink all scripts to ~/.config/shell
This commit is contained in:
Pratik Tripathy
2024-02-09 10:04:49 +05:30
parent 44ccbbfe6e
commit 5765e05ec0
6 changed files with 159 additions and 15 deletions

35
10x_project_access.sh Normal file → Executable file
View File

@@ -1,5 +1,9 @@
#!/bin/sh
# TODO: Alias to quickly add my template .gitignore file to any location
# - Create fuzzy finder for cht.sh & tldr
# - Move all dev prod scripts to its own project
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: ')"
@@ -23,23 +27,24 @@ pnew(){
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
# Until user provides a good directory name or cancels out
while [ -d "$directory/$project_name" ]; do
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 [ -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
if [ -z "$project_name" ]; then
echo "Cancelling..."
return 0
fi
if [ -d "$directory/$project_name" ]; then
echo "'$directory/$project_name' already exists"
fi
done
[ -d "$directory/$project_name" ] || mkdir -p "$directory/$project_name" || return