-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdynalias.sh
More file actions
executable file
·41 lines (32 loc) · 1008 Bytes
/
dynalias.sh
File metadata and controls
executable file
·41 lines (32 loc) · 1008 Bytes
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
#!/usr/bin/env bash
# global exports
export DYNALIAS_ROOT="$HOME/.dynalias"
export DYNALIAS_BIN="$DYNALIAS_ROOT/bin"
export DYNALIAS_LIB="$DYNALIAS_ROOT/lib"
export DYNALIAS_LOG="$DYNALIAS_ROOT/dynalias.log"
export DYNALIAS_CONF="$HOME/.config/dynalias"
export DYNALIAS_OUT="$DYNALIAS_CONF/.output"
# global imports
. "$DYNALIAS_LIB/error.sh"
. "$DYNALIAS_LIB/log.sh"
if [ -z "$1" ]; then
err "Please provide a flag."
err "Try 'dynalias help' for more information."
exit 1
fi
if [ ! -d "$DYNALIAS_ROOT" ]; then
err "The '.dynalias' folder doesn't exist on '\$HOME'."
err "Please make sure to install the project correctly"
exit 1
fi
if [ ! -d "$DYNALIAS_CONF" ]; then
warn "Crating 'dynalias' inside '\$HOME/.config'."
mkdir -p "$DYNALIAS_CONF"
fi
# save the passed command and shift arguments
command=$1
shift
# check if command exists
[ ! -f "$DYNALIAS_BIN/$command.sh" ] \
&& throw "unknown command '$command', use 'dynalias help'"
. "$DYNALIAS_BIN/$command.sh"