49 lines
1.4 KiB
Bash
49 lines
1.4 KiB
Bash
#!/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
|
|
}
|