Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for direnv to second line #53

Merged
merged 7 commits into from
Jun 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 111 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@

## Vitals

Info | Badges
--------------|-------------------------------------
License | [![License][license-image]][license-uri]
License Scan | [![FOSSA Status][fossa-image]][fossa-uri]
Build | [![Build][build-image]][build-uri]
| Info | Badges |
| ------------ | ----------------------------------------- |
| License | [![License][license-image]][license-uri] |
| License Scan | [![FOSSA Status][fossa-image]][fossa-uri] |
| Build | [![Build][build-image]][build-uri] |

### Supported Operating Systems

Name | Version
-------|------------------
macOS | Sierra or greater
ubuntu | 16.04 or greater
fedora | 29 or greater
debian | 9 or greater
centOS | 7 or greater
mint | 19 or greater
| Name | Version |
| ------ | ----------------- |
| macOS | Sierra or greater |
| ubuntu | 16.04 or greater |
| fedora | 29 or greater |
| debian | 9 or greater |
| centOS | 7 or greater |
| mint | 19 or greater |

## Know It

Expand All @@ -37,6 +37,7 @@ including:
* Flush DNS (on macOS)
* Ability to enable and disable hidden files in Finder (on macOS)
* Display of available colors (already set as variables for use elsewhere)
* Display currently active Python virtialenv when using [pyenv][pyenv-url] & [direnv][direnv-url] (bash & zsh)
* ... and much more!

Note: All "extensions" are implemented as scripts added to the path, so it should not interfere with existing
Expand Down Expand Up @@ -121,6 +122,97 @@ In order to test the installation routine for promptMastermind, we use a set of
In addition, [circleci][circleci-uri] is used to build all platforms, including macOS as part of our pull request
validation. Special thanks to [circleci][circleci-uri] for providing the build agents!

## Features

### Two-Line Prompt

The first-line displays username, hostname, and current path.

The second-line emits information about the current branch and status when in a git path. If using [pyenv][pyenv-url] and [direnv][direnv-url] the second-line also displays the currently activated Python virtualenv.

### SDK Installs

[AWS SDK][aws-sdk-url]

```sh
aws-install
```

[Google Cloud SDK][gcloud-sdk-url]

```sh
gcloud-install
```

[.Net SDK][dotnet-sdk-url]

```sh
dotnet-install
```

### Colors

Global colors defined by promotMastermind:

| Name | Color |
| ------------------ | ----------------------- |
| CLR_CLEAR | DEFAULT COLOR |
| CLR_BLACK | ANSI BLACK (GRAY) |
| CLR_RED | ANSI RED |
| CLR_GREEN | ANSI GREEN |
| CLR_YELLOW | ANSI YELLOW |
| CLR_BLUE | ANSI BLUE |
| CLR_MAGENTA | ANSI MAGENTA (PURPLE) |
| CLR_CYAN | ANSI CYAN |
| CLR_WHITE | ANSI WHITE |
| CLR_BRIGHT_BLACK | BRIGHT BLACK (GRAY) |
| CLR_BRIGHT_RED | BRIGHT RED |
| CLR_BRIGHT_GREEN | BRIGHT GREEN |
| CLR_BRIGHT_YELLOW | BRIGHT YELLOW |
| CLR_BRIGHT_BLUE | BRIGHT BLUE |
| CLR_BRIGHT_MAGENTA | BRIGHT MAGENTA (PURPLE) |
| CLR_BRIGHT_CYAN | BRIGHT CYAN |
| CLR_BRIGHT_WHITE | BRIGHT WHITE |

### macOS Commands

Show/Hide Files:

```sh
# show all hidden files
show-all

# hide all hidden files
hide-all
```

Flush DNS:

```sh
flush-dns
```

Set Theme to Monokai:

```sh
theme monokai # general high quality theme that has been around for many years
```

Set Theme to Dark Mode

```sh
theme dark-mode # our own custom theme that is nice and bright for dark mode on macOS
```

### *nix Commands

Install [kind][kind-url]:

```sh
kind-install
```


## Copyright and License

© automotiveMastermind and contributors. Distributed under the MIT license. See [LICENSE][license-uri] for details.
Expand All @@ -136,3 +228,9 @@ validation. Special thanks to [circleci][circleci-uri] for providing the build a

[fossa-image]: https://app.fossa.com/api/projects/custom%2B12139%2Fgit%40github.com%3AautomotiveMastermind%2Fprompt.git.svg?type=shield
[fossa-uri]: https://app.fossa.com/projects/custom%2B12139%2Fgit%40github.com%3AautomotiveMastermind%2Fprompt.git?ref=badge_shield
[pyenv-url]: https://github.com/pyenv/pyenv
[direnv-url]: https://github.com/direnv/direnv/wiki/Python
[kind-url]: https://kind.sigs.k8s.io
[aws-sdk-url]: https://github.com/aws/aws-cli
[gcloud-sdk-url]: https://cloud.google.com/sdk/install
[dotnet-sdk-url]: https://github.com/dotnet/installer
2 changes: 1 addition & 1 deletion src/bash/scripts/eval/set-prompt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ __am_prompt_set_prompt() {
export PROMPT_COMMAND='"\n\u@\h : \w\n" "$(__am_prompt_emit_prompt_arrow)"'
else
# use the git prompt with the prompt arrow
export PROMPT_COMMAND='__posh_git_ps1 "\n\u@\h : \w\n" "$(__am_prompt_emit_prompt_arrow)"'
export PROMPT_COMMAND='__posh_git_ps1 "\n\u@\h : \w\n" "$(__am_prompt_show_virtual_env) $(__am_prompt_emit_prompt_arrow)"'
fi
}

Expand Down
10 changes: 10 additions & 0 deletions src/bash/scripts/eval/show-virtualenv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

# if virutal env and direnv variables are set show virtual env in prompt
__am_prompt_show_virtual_env() {
if [[ -n "$VIRTUAL_ENV" && -n "$DIRENV_DIR" ]]; then
echo "(${VIRTUAL_ENV##*/})"
fi
}

__am_prompt_show_virtual_env
9 changes: 8 additions & 1 deletion src/zsh/scripts/eval/set-prompt
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,15 @@ __am_prompt_set_prompt() {
# set the window title
echo -ne "\033]0;${USER}@${HOSTNAME%%.*} ${PWD}\007"

if [[ -n "$VIRTUAL_ENV" && -n "$DIRENV_DIR" ]]; then
setopt PROMPT_SUBST
local DIR_ENV="(${VIRTUAL_ENV##*/})"
else
local DIR_ENV=""
fi

local NEWLINE=$'\n'
__posh_git_ps1 "${NEWLINE}%n@%m : %~${NEWLINE}" " $AM_PROMPT_ARROW"
__posh_git_ps1 "${NEWLINE}%n@%m : %~${NEWLINE}" "$DIR_ENV $AM_PROMPT_ARROW"
}

# set up the arrow
Expand Down