Created
June 3, 2024 07:26
-
-
Save mikkelrask/abfad59048edaa0a287dcb4488ca897d to your computer and use it in GitHub Desktop.
OS logo shown in prompt. when logging in with SSH
This file contains 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
if [ -n "$SSH_TTY" ]; then | |
SSHPROMPT="%F{blue}$(distrocheck.sh) %F{cyan}($(command cat /etc/hostname)) %F{foreground}" | |
else | |
SSHPROMPT="" | |
fi | |
# Git info % | |
declare GITPROMPT="" | |
function git_prompt_info() { | |
local git_branch=$(git symbolic-ref --short HEAD 2>/dev/null) | |
local git_status=$(git status --porcelain 2>/dev/null) | |
if [[ -n "$git_branch" ]]; then | |
BRANCNAME="F{yellow} $git_branch%F{foreground}" | |
if [[ -n "$git_status" ]]; then | |
CHANGESMADE="%F{green}+ %F{foreground}" | |
fi | |
fi | |
echo "$BRANCHNAME$CHANGESMADE" | |
} | |
DIRECTORYPROMPT="%~ " | |
SUCCESSPROMPT='%(?%F{green}√ %F{foreground}.%F{red}err. %? %1.%F{foreground})' | |
GITPROMPT=$(git_prompt_info) | |
FINALPROMPT="$SSHPROMPT$DIRECTORYPROMPT$GITPROMPT" | |
PS1=$FINALPROMPT |
This file contains 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
# Place this in a folder | |
# that is inclded in $PATH | |
# Checks /etc/os-release | |
# to see what OS we are on | |
# and outputs its logo | |
#!/usr/bin/env bash | |
get_distro() { | |
source /etc/os-release | |
case $ID in | |
arch) l=" ";; | |
ubuntu) l=" ";; | |
alpine) l=" ";; | |
fedora) l=" ";; | |
gentoo) l=" ";; | |
kali) l=" ";; | |
debian) l=" ";; | |
opensuse) l=" ";; | |
centos) l=" ";; | |
*) l=" ";; | |
esac | |
echo $l | |
} | |
get_distro |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment