forked from platformsh/legacy-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplatform.rc
More file actions
58 lines (55 loc) · 1.68 KB
/
Copy pathplatform.rc
File metadata and controls
58 lines (55 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash
# Platform.sh CLI shell configuration.
# Enable auto-completion.
if HOOK=$(platform _completion -g -p platform); then
# Try two commands.
# See https://github.com/stecman/symfony-console-completion/issues/12
echo "$HOOK" | source /dev/stdin
source <(echo "$HOOK") 2>/dev/null
fi
# Run Git commands in the project repository, from any working directory.
function platform_local_git {
local ROOT
ROOT="$(platform dir repo 2>/dev/null)"
# Test the return code of 'platform dir' (it may have written an error
# message to STDOUT).
CODE=$?
if [ "$CODE" = 2 ]; then
echo $0': This can only be run from inside a project directory' >&2
return "$CODE"
elif [ ! "$CODE" = 0 ] || [ ! -d "$ROOT" ]; then
echo $0': Repository not found' >&2
return "$CODE"
fi
cd "$ROOT"
# Run Git with 'status' as the default command.
if [ -z $1 ]; then
git status
else
git $@
fi
local GIT_CODE=$?
# Change back to the previous working directory.
cd - 1>/dev/null
return "$GIT_CODE"
}
alias plgit=platform_local_git
# Run Drush commands on the local environment, from any working directory.
function platform_local_drush {
local GROUP
GROUP="$(platform drush-aliases --no --pipe 2>/dev/null)"
CODE=$?
if [ "$CODE" = 2 ]; then
echo $0': This can only be run from inside a project directory' >&2
return "$CODE"
elif [ ! "$CODE" = 0 ]; then
echo $0': Drush alias group not found' >&2
return "$CODE"
fi
if [ -z $1 ]; then
drush @${GROUP}._local status
else
drush @${GROUP}._local $@
fi
}
alias pldr=platform_local_drush