Recently I stumbled over an article, about how to customize your shell prompt. What really surprised me, is that it lacked one of the most basic tips I learned nearly 20 years back: Always display a timestamp in the prompt, to be able to check how long a process is running or when it ended. (Don’t need it daily, but every so often it saves my butt. ;-)) The other trick is to always have a colorful prompt, to easily discern where output from programs start/stop. In total my PS1 looks like this (with GIT status at the end): [\e[32m]\u[\e[m]@[\e[35m]\h[\e[m] [\e[36m]\A[\e[m] [\e[37m][[\e[m][\e[31m]\w[\e[m][\e[37m]][\e[m]$(__git_ps1 “(%s)”)$

My question is, what customization, tips and tricks do you have for the shell prompt?

2 points
*

Use PS1="▌\t▐\n\w→" to display your local time each time you press enter. And make aliases of lengthy commands such as alias internettest="curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python -" (You need to install python to run this.)

permalink
report
reply
7 points

I make it green for an ssh session, and red when I’m root. That’s it, nothing fancy.

permalink
report
reply
3 points

Damn it! That is such an obvious great idea, I feel like an idiot! Thank you very much! :-)

Any advice/guide how to change the color for ssh sessions?

permalink
report
parent
reply
4 points

Check for the ssh env vars. For example, I use PS1="${SSH_CONNECTION:+\u@\h:}\W\$" to hide the hostname when not on SSH, you could do something similar with the control codes for color.

permalink
report
parent
reply
4 points

If you like customizing your shell, there are really cool things one can do with zsh.

I have mine set up with suggestions to complete the name of the program, or even command line options for it.

permalink
report
reply
4 points

zsh … it is totally awesome, I saw a lot of crazy autocomplete stuff by people using it. I stick to bash mostly because it is simply installed everywhere and good enough for my needs. (With some help like autojump for bash.)

permalink
report
parent
reply
1 point
*

Step 1. Install fish shell

Step 2. Type fish_config

Step 3. Profit

permalink
report
reply
3 points
*

Most prompt customizers have an option for showing how long last command ran and whether it succeeded/failed or simply prompt timestamp, it’s often default. I use Tide, there’s also Starship and a number of others. You can also roll your own ofcourse.

permalink
report
reply

Linux

!linux@lemmy.ml

Create post

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word “Linux” in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

  • Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
  • No misinformation
  • No NSFW content
  • No hate speech, bigotry, etc

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

Community stats

  • 7.5K

    Monthly active users

  • 6.6K

    Posts

  • 179K

    Comments