aliases
This commit is contained in:
parent
9dde2c0aeb
commit
76819f7b95
2
.gitignore
vendored
2
.gitignore
vendored
@ -7,5 +7,5 @@ systems/*
|
||||
|
||||
var/
|
||||
|
||||
.alias
|
||||
.aliases
|
||||
.systems
|
||||
22
.profile
22
.profile
@ -1,11 +1,25 @@
|
||||
# GIT branch in bash START
|
||||
# bin
|
||||
. $DEV_ENV_PATH/bin/denv
|
||||
. $DEV_ENV_PATH/bin/dcom
|
||||
. $DEV_ENV_PATH/bin/drun
|
||||
. $DEV_ENV_PATH/bin/git
|
||||
# /bin
|
||||
|
||||
# alias
|
||||
if [ -f "$DEV_ENV_PATH/.aliases" ]; then
|
||||
. "$DEV_ENV_PATH/.aliases"
|
||||
fi
|
||||
# /alias
|
||||
|
||||
# GIT branch in bash
|
||||
parse_git_branch() {
|
||||
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
|
||||
}
|
||||
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ '
|
||||
# GIT branch in bash END
|
||||
# /GIT branch in bash
|
||||
|
||||
# SSH Setup START
|
||||
|
||||
# SSH
|
||||
SSH_ENV="$HOME/.ssh/agent-environment"
|
||||
function start_agent {
|
||||
echo "Initialising new SSH agent..."
|
||||
@ -26,4 +40,4 @@ if [ -f "$SSH_ENV" ]; then
|
||||
else
|
||||
start_agent
|
||||
fi
|
||||
# SSH Setup END
|
||||
# /SSH
|
||||
2
bin/denv
2
bin/denv
@ -2,7 +2,7 @@
|
||||
ENV_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/../" &> /dev/null && pwd )
|
||||
|
||||
denv() {
|
||||
if [ ! -z $1 ] then
|
||||
if [ ! -z $1 ] ; then
|
||||
$ENV_DIR/$1
|
||||
else
|
||||
cd $ENV_DIR
|
||||
|
||||
6
bin/drun
6
bin/drun
@ -16,7 +16,11 @@ drun() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
docker exec -it "$CONTAINER_ID" $COMMAND
|
||||
if [[ -t 0 && -t 1 ]]; then
|
||||
docker exec -it "$CONTAINER_ID" $COMMAND
|
||||
else
|
||||
docker exec "$CONTAINER_ID" $COMMAND
|
||||
fi
|
||||
}
|
||||
|
||||
_drun_completion() {
|
||||
|
||||
4
init
4
init
@ -9,6 +9,10 @@ then
|
||||
denv_info_msg "[dev-env]: docker-compose.yml created"
|
||||
fi
|
||||
|
||||
# Update .aliases
|
||||
$ENV_DIR/script/write_aliases
|
||||
echo ""
|
||||
|
||||
# Update .profile
|
||||
$ENV_DIR/script/update_profile
|
||||
echo ""
|
||||
|
||||
@ -30,7 +30,8 @@ else
|
||||
denv_echo_msg "[dev-env]: Section does not exists. Adding contents..."
|
||||
fi
|
||||
|
||||
ENV_DIR_STRING="#DEV-ENV\nDEV_ENV_PATH=$ENV_DIR\n#DEV-ENV"
|
||||
# Add contents
|
||||
echo -e "\n$START_MARKER\n$TEMPLATE_CONTENT\n$END_MARKER" >> "$PROFILE_FILE"
|
||||
echo -e "\n$START_MARKER\n$ENV_DIR_STRING\n$TEMPLATE_CONTENT\n$END_MARKER" >> "$PROFILE_FILE"
|
||||
|
||||
denv_success_msg "[dev-env]: Successfully updated $PROFILE_FILE"
|
||||
|
||||
24
script/write_aliases
Executable file
24
script/write_aliases
Executable file
@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
ENV_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/.." &> /dev/null && pwd )
|
||||
CONFIG_FILE="$ENV_DIR/.systems"
|
||||
source $ENV_DIR/bin/denv_msg
|
||||
|
||||
# Check if .systems configuration exists
|
||||
if [ ! -f "$CONFIG_FILE" ]; then
|
||||
denv_error_msg "$CONFIG_FILE not found."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "" > "$ENV_DIR/.aliases"
|
||||
|
||||
# Iterate through all lines in .systems configuration
|
||||
while IFS=' ' read -r IDENTIFIER DIRECTORY GIT; do
|
||||
# Skip comments and emtpy lines
|
||||
if [[ "$IDENTIFIER" =~ ^#.* ]] || [ -z "$IDENTIFIER" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
DIRECTORY="systems/$DIRECTORY"
|
||||
echo "alias goto-$IDENTIFIER='cd \$DEV_ENV_PATH/$DIRECTORY'" >> "$ENV_DIR/.aliases"
|
||||
|
||||
done < "$CONFIG_FILE"
|
||||
Loading…
Reference in New Issue
Block a user