\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{gregcheater} \pdfinfo{ /Title (ps1-environment-variable.pdf) /Creator (Cheatography) /Author (gregcheater) /Subject (PS1 environment variable Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{A3A3A3} \definecolor{LightBackground}{HTML}{F3F3F3} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{PS1 environment variable Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{gregcheater} via \textcolor{DarkBackground}{\uline{cheatography.com/26582/cs/7537/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}gregcheater \\ \uline{cheatography.com/gregcheater} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 15th March, 2016.\\ Updated 13th May, 2016.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{PS1 code}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{\{\{fa-square-o\}\}\textbackslash{}a : an ASCII character} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{\{\{fa-square-o\}\}\textbackslash{}d : the date in "Weekday Month Date" format} \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{\{\{fa-square-o\}\}\textbackslash{}D\{format\} : the format is passed to strftime(3) and the result is inserted into the prompt string; an empty format results in a locale-specific time representation. The braces are required} \tn % Row Count 8 (+ 5) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{\{\{fa-square-o\}\}\textbackslash{}e : an ASCII escape character} \tn % Row Count 9 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{\{\{fa-square-o\}\}\textbackslash{}h : the hostname up to the first '.'} \tn % Row Count 11 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{\{\{fa-square-o\}\}\textbackslash{}H : the hostname} \tn % Row Count 12 (+ 1) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{\{\{fa-square-o\}\}\textbackslash{}j : the number of jobs currently managed by the shell} \tn % Row Count 14 (+ 2) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{\{\{fa-square-o\}\}\textbackslash{}l : the basename of the shell's terminal device name} \tn % Row Count 16 (+ 2) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{\{\{fa-square-o\}\}\textbackslash{}n : a new line} \tn % Row Count 17 (+ 1) % Row 9 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{\{\{fa-square-o\}\}\textbackslash{}r : a carriage return} \tn % Row Count 18 (+ 1) % Row 10 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{\{\{fa-square-o\}\}\textbackslash{}s : the name of the shell, the basename of \$0 (the portion following the final slash)} \tn % Row Count 21 (+ 3) % Row 11 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{\{\{fa-square-o\}\}\textbackslash{}t : the current time in 24-hour HH:MM:SS format} \tn % Row Count 23 (+ 2) % Row 12 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{\{\{fa-square-o\}\}\textbackslash{}T : the current time in 12-hour HH:MM:SS format} \tn % Row Count 25 (+ 2) % Row 13 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{\{\{fa-square-o\}\}\textbackslash{}@ : the current time in 12-hour am/pm format} \tn % Row Count 27 (+ 2) % Row 14 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{\{\{fa-square-o\}\}\textbackslash{}A : the current time in 24-hour HH:MM format} \tn % Row Count 29 (+ 2) % Row 15 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{\{\{fa-square-o\}\}\textbackslash{}u : the username of the current user} \tn % Row Count 31 (+ 2) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{PS1 code (cont)}} \tn % Row 16 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{\{\{fa-square-o\}\}\textbackslash{}v : the version of bash} \tn % Row Count 1 (+ 1) % Row 17 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{\{\{fa-square-o\}\}\textbackslash{}V : the release of bash, version + patch level (e.g., 2.00.0)} \tn % Row Count 3 (+ 2) % Row 18 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{\{\{fa-square-o\}\}\textbackslash{}w : the current working directory, with \$HOME abbreviated with \textasciitilde{}} \tn % Row Count 5 (+ 2) % Row 19 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{\{\{fa-square-o\}\}\textbackslash{}W : the basename of the current working directory, with \$HOME abbreviated with \textasciitilde{}} \tn % Row Count 7 (+ 2) % Row 20 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{\{\{fa-square-o\}\}\textbackslash{}! : the history number of the last command} \tn % Row Count 9 (+ 2) % Row 21 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{\{\{fa-square-o\}\}\textbackslash{}\# : the command number of the last command} \tn % Row Count 11 (+ 2) % Row 22 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{\{\{fa-square-o\}\}\textbackslash{}\$ : if the effective UID is 0, a \#, otherwise a \$} \tn % Row Count 13 (+ 2) % Row 23 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{\{\{fa-square-o\}\}\textbackslash{}nnn : the character corresponding to the octal number nnn} \tn % Row Count 15 (+ 2) % Row 24 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{\{\{fa-square-o\}\}\textbackslash{}\textbackslash{} : a backslash} \tn % Row Count 16 (+ 1) % Row 25 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{\{\{fa-square-o\}\}\textbackslash{}{[} : begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt} \tn % Row Count 19 (+ 3) % Row 26 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{\{\{fa-square-o\}\}\textbackslash{}{]} : end a sequence of non-printing characters} \tn % Row Count 21 (+ 2) % Row 27 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{\{\{fa-square-o\}\} everything else in terpreted literraly} \tn % Row Count 23 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{PS1 formating}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{\{\{fa-square-o\}\}\textbackslash{}e{[}{\bf{code}}m : indicate the start of a formating} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{\{\{fa-square-o\}\}\textbackslash{}e{[}m : indicate the end of all formating} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{\{\{fa-square-o\}\}{\bf{code}} : {\bf{set}};{\bf{colour}};{\bf{background}}} \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{3.7881 cm} x{4.4469 cm} x{3.9528 cm} x{4.2822 cm} } \SetRowColor{DarkBackground} \mymulticolumn{4}{x{17.67cm}}{\bf\textcolor{white}{set, reset, foreground colours, background colours}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{SET}}\{\{bb\}\} & {\bf{RESET}}\{\{bb\}\} & {\bf{FOREGROUND}}\{\{bb\}\} & {\bf{BACKGROUND}}\{\{bb\}\} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \{\{fa-square-o\}\}1 : \seqsplit{bold/bright} & \{\{fa-square-o\}\}0 : reset all & \{\{fa-square-o\}\}30 : black & \{\{fa-square-o\}\}40 : black \tn % Row Count 7 (+ 4) % Row 2 \SetRowColor{LightBackground} \{\{fa-square-o\}\}2 : dim & \{\{fa-square-o\}\}1 : reset \seqsplit{bold/bright} & \{\{fa-square-o\}\}31 : red & \{\{fa-square-o\}\}41 : red \tn % Row Count 11 (+ 4) % Row 3 \SetRowColor{white} \{\{fa-square-o\}\}4 : \seqsplit{underlined} & \{\{fa-square-o\}\}2 : reset dim & \{\{fa-square-o\}\}32 : green & \{\{fa-square-o\}\}42 : green \tn % Row Count 15 (+ 4) % Row 4 \SetRowColor{LightBackground} \{\{fa-square-o\}\}5 : blink & \{\{fa-square-o\}\}24 : reset \seqsplit{underlined} & \{\{fa-square-o\}\}33 : yellow & \{\{fa-square-o\}\}43 : yellow \tn % Row Count 19 (+ 4) % Row 5 \SetRowColor{white} \{\{fa-square-o\}\}7 : reverse & \{\{fa-square-o\}\}25 : reset blink & \{\{fa-square-o\}\}34 : blue & \{\{fa-square-o\}\}44 : blue \tn % Row Count 23 (+ 4) % Row 6 \SetRowColor{LightBackground} \{\{fa-square-o\}\}8 : hidden & \{\{fa-square-o\}\}27 : reset reverse & \{\{fa-square-o\}\}35 : magenta & \{\{fa-square-o\}\}45 : magenta \tn % Row Count 27 (+ 4) % Row 7 \SetRowColor{white} & \{\{fa-square-o\}\}28 : reset hidden & \{\{fa-square-o\}\}36 : cyan & \{\{fa-square-o\}\}46 : cyan \tn % Row Count 31 (+ 4) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{3.7881 cm} x{4.4469 cm} x{3.9528 cm} x{4.2822 cm} } \SetRowColor{DarkBackground} \mymulticolumn{4}{x{17.67cm}}{\bf\textcolor{white}{set, reset, foreground colours, background colours (cont)}} \tn % Row 8 \SetRowColor{LightBackground} & & \{\{fa-square-o\}\}37 : light gray & \{\{fa-square-o\}\}47 : light gray \tn % Row Count 4 (+ 4) % Row 9 \SetRowColor{white} & & \{\{fa-square-o\}\}39 : default & \{\{fa-square-o\}\}49 : defautl \tn % Row Count 7 (+ 3) % Row 10 \SetRowColor{LightBackground} & & \{\{fa-square-o\}\}90 : dark gray & \{\{fa-square-o\}\}100 : dark gray \tn % Row Count 11 (+ 4) % Row 11 \SetRowColor{white} & & \{\{fa-square-o\}\}91 : light red & \{\{fa-square-o\}\}101 : light red \tn % Row Count 15 (+ 4) % Row 12 \SetRowColor{LightBackground} & & \{\{fa-square-o\}\}92 : light green & \{\{fa-square-o\}\}102 : light green \tn % Row Count 19 (+ 4) % Row 13 \SetRowColor{white} & & \{\{fa-square-o\}\}93: light rellow & \{\{fa-square-o\}\}103 : light yellow \tn % Row Count 23 (+ 4) % Row 14 \SetRowColor{LightBackground} & & \{\{fa-square-o\}\}94 : light blue & \{\{fa-square-o\}\}104 : light blue \tn % Row Count 27 (+ 4) % Row 15 \SetRowColor{white} & & \{\{fa-square-o\}\}95: light magenta & \{\{fa-square-o\}\}105 : light magenta \tn % Row Count 31 (+ 4) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{3.7881 cm} x{4.4469 cm} x{3.9528 cm} x{4.2822 cm} } \SetRowColor{DarkBackground} \mymulticolumn{4}{x{17.67cm}}{\bf\textcolor{white}{set, reset, foreground colours, background colours (cont)}} \tn % Row 16 \SetRowColor{LightBackground} & & \{\{fa-square-o\}\}96 : light cyan & \{\{fa-square-o\}\}106 : light cyan \tn % Row Count 4 (+ 4) % Row 17 \SetRowColor{white} & & \{\{fa-square-o\}\}97 : white & \{\{fa-square-o\}\}107 : white \tn % Row Count 7 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}----} \end{tabularx} \par\addvspace{1.3em} \end{document}