Make some tweaks to profile and functions
This commit is contained in:
parent
16448e5d8d
commit
6c68f369ce
@ -1,4 +1,4 @@
|
||||
#! /bin/sh
|
||||
#! /bin/bash
|
||||
#
|
||||
# .functions
|
||||
# Functions for interactive shells
|
||||
@ -19,6 +19,15 @@ proj() {
|
||||
if [ -d "$projdir" ]; then
|
||||
# It exists
|
||||
cd "$projdir" || return 50
|
||||
# Run code if we have it
|
||||
# The fun part is this environment file can access some vars about the proj
|
||||
local envfile="$projdir/.env"
|
||||
if [ -r "$envfile" ]; then
|
||||
. "$envfile"
|
||||
echo "Sourced environment file for project"
|
||||
# Also mark an envvar to ensure we can detect this condition
|
||||
export PROJECT="$projname"
|
||||
fi
|
||||
else
|
||||
# It does not exist
|
||||
echo "Creating new project \"$projname\""
|
||||
@ -53,18 +62,3 @@ _proj() {
|
||||
COMPREPLY=($(compgen -W "$COMPREPLY" "${COMP_WORDS[COMP_CWORD]}"))
|
||||
return 0
|
||||
}
|
||||
# Autocompletion for zsh
|
||||
compdef _proj proj > /dev/null 2>&1 && \
|
||||
_proj() {
|
||||
#! /usr/bin/env zsh
|
||||
# It's okay, shellcheck
|
||||
# We zsh now
|
||||
# shellcheck disable=2039
|
||||
for dir in "$HOME"/Projects/*; do
|
||||
temp="$(basename "$dir")"
|
||||
temp="${reply//[^ a-zA-Z0-9.]/}"
|
||||
reply+=" $temp"
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
|
@ -309,6 +309,10 @@ _ps1bash() {
|
||||
elif [ "$USER" != "salt" ]; then
|
||||
_prefix="${fg_bold}${fg_yellow}$USER${r}${fg_yellow}:${r}${_prefix}"
|
||||
fi
|
||||
# If we're in a PROJECT, post that envvar
|
||||
if [ -n "$PROJECT" ]; then
|
||||
_prefix="${_prefix}${fg_bold}${fg_blue}$PROJECT${r}${fg_blue}:${r}"
|
||||
fi
|
||||
# Color PWD
|
||||
_prefix="${_prefix}${fg_blue}"
|
||||
# Show the tilde instead of $HOME
|
||||
|
Loading…
Reference in New Issue
Block a user