forked from acook/git-prompt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprompt_helpers
executable file
·25 lines (20 loc) · 1.28 KB
/
prompt_helpers
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash
# Just some stuff to make writing prompts easier
# Set a Terminal's title with this, saves a lot of weird strings from the prompts
function title { echo -ne "\\033]0;$*\007"; }
# Gets the present working directory and returns just the last 2 directories, good for shortening titles and prompts
function PWD { tmp=${PWD%/*/*}; [ ${#tmp} -gt 0 -a "$tmp" != "$PWD" ] && echo ${PWD:${#tmp}+1} || echo $PWD; }
# Does the same thing, but for any path
function shortpath { tmp=${1%/*/*}; [ ${#tmp} -gt 0 -a "$tmp" != "$1" ] && echo ${1:${#tmp}+1} || echo $1; }
function colorful_hostname {
echo $(fgc 31)`hostname`$(fgc 39):
}
# Here's a bunch of my old prompt strings, I should probably check these out and toss the crappy ones
#PS1="\$?-\t | \$(PWD)\n\r\$ "
#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
#PS1='${debian_chroot:+($debian_chroot)}\033[00;31m\u@\h:\033[01;33m\w\033[00m\n\r\[\033[01;31m\$\033[00m\] '
#PS1='\033]0;$(PWD)\007\033[00;31m\u@\h:\033[01;33m\w\033[00m\n\r\[\033[01;31m\$\033[00m\] '
#PS1='\[$(title $(PWD))$(fgx 154)\]\w\n\[\r\]\[$(fgx 26)\]\$\[$(ansi_reset)\] '
# Here's the old, outdated way of setting Terminal titles
#function prompt_command { echo -ne "\033]0;$(PWD)\007" }
#PROMPT_COMMAND="prompt_command"