aboutsummaryrefslogtreecommitdiff
path: root/bash/bashrc.d/prompt.bash
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2014-10-23 14:12:45 +1300
committerTom Ryder <tom@sanctum.geek.nz>2014-10-23 14:12:45 +1300
commit644aae432d9bcc962bb27546f5838c34949a08db (patch)
treef22164d42bf86b14c8a9cc256d38ff0e41ea116a /bash/bashrc.d/prompt.bash
parentError out on bad prompt calls (diff)
downloaddotfiles-644aae432d9bcc962bb27546f5838c34949a08db.tar.gz
dotfiles-644aae432d9bcc962bb27546f5838c34949a08db.zip
Show nice level of current process if /proc
Diffstat (limited to 'bash/bashrc.d/prompt.bash')
-rw-r--r--bash/bashrc.d/prompt.bash17
1 files changed, 15 insertions, 2 deletions
diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash
index b9a834b8..d6a2f65a 100644
--- a/bash/bashrc.d/prompt.bash
+++ b/bash/bashrc.d/prompt.bash
@@ -14,7 +14,7 @@ prompt() {
on)
# Set up pre-prompt command and prompt format
PROMPT_COMMAND='declare -i PROMPT_RETURN=$? ; history -a'
- PS1='[\u@\h:\w]$(prompt vcs)$(prompt job)$(prompt ret)\$'
+ PS1='[\u@\h:\w]$(prompt nice)$(prompt job)$(prompt vcs)$(prompt ret)\$'
# If Bash 4.0 is available, trim very long paths in prompt
if ((BASH_VERSINFO[0] >= 4)) ; then
@@ -243,6 +243,19 @@ prompt() {
printf '{%d}' "$jobc"
fi
;;
+
+ # Show the nice level of the current process with a circumflex (/proc
+ # systems only)
+ nice)
+ if [[ -r /proc/"$$"/stat ]] ; then
+ read -r _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ nice _ \
+ < /proc/"$$"/stat
+ if ((nice != 20)) ; then
+ printf '^%d' "$((nice - 20))"
+ fi
+ fi
+ ;;
+
# Print error
*)
printf '%s: Unknown command %s\n' "$FUNCNAME" "$1" >&2
@@ -251,7 +264,7 @@ prompt() {
}
# Complete words
-complete -W 'on off git hg svn vcs ret job' prompt
+complete -W 'on off git hg svn vcs ret job nice' prompt
# Start with full-fledged prompt
prompt on