Bash snippets

From vegard.wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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.