-
Configured PS1 which had been pending for several days. I wanted a simple way to know if I am inside a git directory or not and nothing else (not using zsh, not powerlevel10k, just bash). So I did this and here is the output. I followed arch wiki which says to avoid using
PROMPT_COMMANDfor printing characters to terminal because bash doesn't count those characters and so, it may end up placing the cursor at a position which doesn't include the calculation of characters fromPROMPT_COMMAND. However, it could have been used to reassign PS1 but my PS1 was already long. PS1 is set once when it used for the first time, so the trick to embed commands is to avoid expansion the first time either by single quotes or backslashing the dollar of command subsititution. It will be expanded, when the prompt is actually display.
-
read a bit of man pages for several commands.
-
help <shellbuitin>instead of<shellbuitin> --help(example, echo --help will print --help). -
man builtinswill show all builtins. -
Anyways, I usually try all these things,
man program,program --help,info program,help program, and either one or more will give me what I want. -
ls -tto sort files in descending order last-modified. -
ls -Falhitis a good use along with already aliasedls='ls --color=auto'.
- PS1,2,3,4, PROMPT_COMMAND
- Customizing the prompt PS1 But I would suggest and likely follow (1) The linux command line book for colors etc (2) arch wiki for embedding commands.
- basic commands Again, I will strongly suggest the linux command line book by William Shotts and some of Luke Smith's videos.
- Explore the Linux file system
- Linux File System
- Simple Terminal Commands on Ubuntu
- Solaris Unix Commands