Difference between revisions of "Bash snippets"

From vegard.wiki
Jump to navigation Jump to search
(add image)
 
Line 6: Line 6:
 
export PS1='\[\033[0;32m\][\[\033[0;31m\]\u@\h \[\033[0;34m\]\w \[\033[0;33m\]$?\[\033[0;32m\]]\n\[\033[0m\]\$\[\033[0m\] '
 
export PS1='\[\033[0;32m\][\[\033[0;31m\]\u@\h \[\033[0;34m\]\w \[\033[0;33m\]$?\[\033[0;32m\]]\n\[\033[0m\]\$\[\033[0m\] '
 
</source>
 
</source>
 +
 +
[[File:prompt.png|thumb|Example output.]]
  
 
Output (modulo colours):
 
Output (modulo colours):

Latest revision as of 08:57, 9 April 2020

Prompts

export PS1='\[\033[0;32m\][\[\033[0;31m\]\u@\h \[\033[0;34m\]\w \[\033[0;33m\]$?\[\033[0;32m\]]\n\[\033[0m\]\$\[\033[0m\] '
Example output.

Output (modulo colours):

[vegard@t460 ~ 0]
$ 

See also: http://man7.org/linux/man-pages/man1/bash.1.html#PROMPTING

Adding to the search path

# https://stackoverflow.com/a/9631350/1697183
export LD_LIBRARY_PATH="/foo/bar${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"

This is more secure than plain appending, which can create empty components (e.g. a trailing ":") which are interpreted as "current directory" and lead to DLL search order hijacking.