- Made pnew() loop till a valid name is given. - Made bootstrap script to symlink all scripts to ~/.config/shell
54 lines
1.6 KiB
Bash
Executable File
54 lines
1.6 KiB
Bash
Executable File
#!/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: ')"
|
|
|
|
# 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
|
|
|
|
# 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 [ -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
|
|
|
|
cd "$directory/$project_name" || return
|
|
nvim
|
|
}
|