Advertisement
disu1950

BASH PROMPT VARIABLES

Jul 4th, 2024
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.18 KB | Source Code | 0 0
  1.  
  2. <!DOCTYPE html>
  3. <html>
  4.     <head>
  5.         <title>W3docs</title>
  6.     </head>
  7.     <div class="container">
  8.       <h2>Bash prompt variables</h2>
  9.       <p>These are the variable substitutions used above.</p>
  10.       <pre class="legend">\u     user
  11. \h     hostname
  12. \w     ~/path/to/directory
  13. </pre>
  14.       <p>For reference, this is a list of all the valid bash prompt variables from the PROMPTING section in the bash man pages in `man bash`</p>
  15.       <pre class="bash-variable-list">\a     an ASCII bell character (07)
  16. \d     the date in "Weekday Month Date" format (e.g., "Tue
  17.        May 26")
  18. \D{format}
  19.        the format is passed to strftime(3) and the result
  20.        is inserted into the prompt string; an empty format
  21.        results in a locale-specific time representation.
  22.        The braces are required
  23. \e     an ASCII escape character (033)
  24. \h     the hostname up to the first `.'
  25. \H     the hostname
  26. \j     the number of jobs currently managed by the shell
  27. \l     the basename of the shell's terminal device name
  28. \n     newline
  29. \r     carriage return
  30. \s     the name of the shell, the basename of $0 (the
  31.        portion following the final slash)
  32. \t     the current time in 24-hour HH:MM:SS format
  33. \T     the current time in 12-hour HH:MM:SS format
  34. \@     the current time in 12-hour am/pm format
  35. \A     the current time in 24-hour HH:MM format
  36. \u     the username of the current user
  37. \v     the version of bash (e.g., 2.00)
  38. \V     the release of bash, version + patch level (e.g.,
  39.        2.00.0)
  40. \w     the current working directory, with $HOME
  41.        abbreviated with a tilde (uses the value of the
  42.        PROMPT_DIRTRIM variable)
  43. \W     the basename of the current working directory, with
  44.        $HOME abbreviated with a tilde
  45. \!     the history number of this command
  46. \#     the command number of this command
  47. \$     if the effective UID is 0, a #, otherwise a $
  48. \nnn   the character corresponding to the octal number nnn
  49. \\     a backslash
  50. \[     begin a sequence of non-printing characters, which
  51.        could be used to embed a terminal control sequence
  52.        into the prompt
  53. \]     end a sequence of non-printing characters
  54. </pre>
  55.     </div>
  56.   </section>
  57.  
  58. </html>
  59.  
Tags: BASH Prompt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement