Last active
January 3, 2026 14:43
-
-
Save nejdetckenobi/e682b400f4b826f3af3f8e9a9046a49c to your computer and use it in GitHub Desktop.
This is a custom PS1 configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| autoload -U colors && colors | |
| export VIRTUAL_ENV_DISABLE_PROMPT=1 | |
| function _is_git_repo() { | |
| git rev-parse --is-inside-work-tree &>/dev/null | |
| } | |
| function _git_branch() { | |
| git symbolic-ref --short HEAD 2>/dev/null | |
| } | |
| # OSC 8 hyperlink helper | |
| function _hyperlink() { | |
| local url="$1" | |
| local text="$2" | |
| print -n $'%{\e]8;;'"$url"$'\a%}'"$text"$'%{\e]8;;\a%}' | |
| } | |
| function _prompt_flags() { | |
| local parts=() | |
| # SSH session → S (bold blue, hyperlink → ssh://remote) | |
| if [[ -n "$SSH_CONNECTION" ]]; then | |
| local remote_ip="${SSH_CONNECTION%% *}" | |
| local ssh_link="$(_hyperlink "ssh://${remote_ip}" "S")" | |
| parts+=("%B%F{blue}${ssh_link}%f%b") | |
| fi | |
| # Git repo → G (bold red, hyperlink → branch name) | |
| if _is_git_repo; then | |
| local branch="$(_git_branch)" | |
| if [[ -n "$branch" ]]; then | |
| parts+=("%B%F{red}$(_hyperlink "$branch" "G")%f%b") | |
| fi | |
| fi | |
| # Python venv → V (bold yellow, hyperlink → venv path) | |
| if [[ -n "$VIRTUAL_ENV" ]]; then | |
| parts+=("%B%F{yellow}$(_hyperlink "file://${VIRTUAL_ENV}" "V")%f%b") | |
| fi | |
| if (( ${#parts[@]} )); then | |
| echo " %B%F{white}[%f%b${(j: :)parts}%B%F{white}]%f%b" | |
| fi | |
| } | |
| PS1='$(_prompt_flags) %B%F{white}%1~%f%b %F{red}➜%f ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment