Skip to content

Instantly share code, notes, and snippets.

@textarcana
textarcana / exit-status-in-prompt.sh
Last active March 1, 2024 05:28
Show a green smiley or red frowny face to inidicate whether the last command exited with a good or bad exit status.
RESET="\[\017\]"
NORMAL="\[\033[0m\]"
RED="\[\033[31;1m\]"
GREEN="\[\033[32;1m\]"
SMILEY="${GREEN}:)${NORMAL}"
FROWNY="${RED}:(${NORMAL}"
EMOTE="if [ \$? = 0 ]; then echo \"${SMILEY}\"; else echo \"${FROWNY}\"; fi"
export PS1="${RESET}\n\`${EMOTE}\` \
\u@\h \
@gschueler
gschueler / .bash_profile
Created June 4, 2014 18:51
🍺 or 💩
function prompt_func() {
previous_return_value=$?;
prompt="\h:\W \u"
if test $previous_return_value -eq 0
then
PS1="${prompt}🍺 "
else
PS1="${prompt}💩 "
fi
}
@BugRoger
BugRoger / ssh-background
Created January 21, 2011 16:02
Changes iTerm2's background color based on host configuration
#!/bin/bash
# Installation:
# 1. Save this script to /some/bin/ssh-background
# 2. chmod 755 /some/bin/ssh-background
# 3. alias ssh=/some/bin/ssh-background
# 4. Configure your host colors below.
set_color() {
local HEX_FG=$1
local HEX_BG=$2