Skip to content

Commit cc837ee

Browse files
shellrc: added alias to delete workspace
1 parent 4b8edc2 commit cc837ee

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

.oh-my-shell/shellrc/plugins/development/aliases.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ alias tcode="cd \"${_DEFAULT_DEVELOPMENT_DIR}/\$(find ${_DEFAULT_DEVELOPMENT_DIR
99
# Create workspace
1010
# Usage: code_create_company_workspace_project "company_name" "workspace_name" "project_name"
1111
alias code_create_workspace="f_code_create_workspace ${_DEFAULT_DEVELOPMENT_DIR} "
12+
13+
# Delete a workspace
14+
# Usage: workspace_delete
15+
alias code_wipe_workspace="f_code_wipe_workspace ${_DEFAULT_DEVELOPMENT_DIR}"
Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,34 @@
1-
function f_code_create_company_workspace_project() {
1+
f_code_create_company_workspace_project() {
22
local code_dir="$1"
33
local company="$(echo $2 | tr '[:lower:]' '[:upper:]')"
44
local workspace="$(echo $3 | tr '[:lower:]' '[:upper:]')_WORKSPACE"
55
local project="$(echo $4 | tr '[:lower:]' '[:upper:]')"
66

77
mkdir -p "${code_dir}/$company/$workspace/$project"
88
}
9+
10+
# POSIX-compatible script to delete everything below folders
11+
# ending with *_WORKSPACE
12+
f_code_wipe_workspace() {
13+
# Starting directory (default: current directory)
14+
local start_dir="$1"
15+
16+
start_dir="$(realpath "$start_dir")"
17+
18+
# Find matching directories
19+
workspace_dir="$(find "$start_dir" -maxdepth 1 -type d -name '*_WORKSPACE' -printf '%P\n' | fzf)"
20+
21+
echo "Confirm wiping $workspace_dir ? [y/n]"
22+
workspace_dir="$start_dir/$workspace_dir"
23+
read answer
24+
25+
case "$answer" in
26+
[Yy])
27+
command rm -rf "$workspace_dir"
28+
;;
29+
*)
30+
echo "Aborted."
31+
;;
32+
esac
33+
}
34+

0 commit comments

Comments
 (0)