this post was submitted on 21 Oct 2023
97 points (96.2% liked)

Linux

48092 readers
899 users here now

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

Related Communities

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

founded 5 years ago
MODERATORS
 

Hi. I've been using powerlevel10k for a long time, but a few days ago, I decided I wanted to customize it a bit. I opened the .p10k.zsh file, and I was shocked. It's really massive, with TONS of options. I've been digging through for a few hours already, and it's absolutely amazing how much you can customize it without actually programming anything. I was wondering what other people are using. So my questions are:

  • Do you customize your shell prompt?
  • If yes, do you use some framework or pre-made theme, or do you just configure it the vanilla way in your bashrc/zshrc/...
  • How is your experiences with it so far?
  • Share screenshot of your prompts, please (Sadly, my prompt is currently half done, so I can't really share it)
top 50 comments
sorted by: hot top controversial new old
[–] nbailey@lemmy.ca 39 points 1 year ago (3 children)

I use plain old bash with the plain old .bashrc that ships with Debian. I’ll bolt on a git-branch-aware function into the prompt here and there, but that’s about it.

Why? I ssh into a few dozen machines most days and my shitty little lizard brain can’t deal with everything being different on each box. So as much as I appreciate zsh, powerline plug-ins, all that glitzy stuff, I’ll be a late adopter when it comes to plain old Debian stable…

[–] sep@lemmy.world 5 points 1 year ago

The only way i function. Am usualy ssh'd into 3-5 machines at any given time.

[–] herrvogel@lemmy.world 5 points 1 year ago (1 children)

I wrote an Ansible playbook to install my zsh stuffs into a remote machine. I don't run it against every machine though, just the ones where I ssh into particularly often and have the freedom to customize the shell.

[–] whatwhatwhatwhat@lemmy.world 10 points 1 year ago

freedom to customize the shell

This is always the issue for me – I ssh into several machines for various clients every day. All of those clients have one thing in common: equally strict and inconsistent policies about what packages you can use from where and for what reason. “I like this shell better” would never fly, sadly.

load more comments (1 replies)
[–] dinckelman@lemmy.world 21 points 1 year ago* (last edited 1 year ago) (4 children)

Fish, with Starship. It does everything I need it to, completely unmodified. In comparison, zsh barely reached feature parity with a dozen plugins, and I just don't want to spend my time on that

[–] Astaroth@lemm.ee 3 points 1 year ago

I love fish.

Sometimes I wonder why people think using the terminal is so hard, then every once in a while when I'm not on my home PC and have to use Bash I get reminded of why

 

I've been meaning to try zsh since it can supposedly do everything fish can while still being posix compliant, but I've never felt the need to not be using fish so I just never got around to it

[–] seitanic@lemmy.sdf.org 2 points 1 year ago (2 children)

Fish, with Starship.

Also a Garuda user?

load more comments (2 replies)
load more comments (2 replies)
[–] starman@programming.dev 21 points 1 year ago* (last edited 1 year ago) (2 children)
[–] ENipo@lemmy.world 7 points 1 year ago (1 children)

Starship is great! I use it with zsh

[–] redw0rm@kerala.party 9 points 1 year ago

And i use it with fish :)

[–] winety 2 points 1 year ago (1 children)

How is Nushell? Is it stable?

load more comments (1 replies)
[–] hellfire103@sopuli.xyz 13 points 1 year ago* (last edited 1 year ago)

I use Zsh with the Oh My Zsh! framework, and I use a different theme depending on which subuserland I’m in, by customising ~/.zshrc. For example, I use the gentoo theme on Debian and its derivatives, agnoster on NixOS, darkblood on Arch, strug for Mageia, apple on my macOS device, aussiegeek on FreeBSD, and gallifrey on OpenBSD. Different themes helps me remember which package manager to use and which distro-specific commands will work.

I'll send some screenshots in a bit, when I boot up my PC.

I like Zsh because of its tab completion and command history. I also quite like its plugins.

Before anyone asks, I have tried Fish before, and I prefer Zsh. I have tried configuring Bash before, and I prefer Zsh. I have played with Ksh and Tcsh on BSD, and I prefer Zsh. I used PowerShell a long time ago, and I prefer Zsh.

[–] Guenther_Amanita@feddit.de 12 points 1 year ago* (last edited 1 year ago) (1 children)

I just use the default fish without any modifications.

To be fair, I don't use the terminal that often.

Even for my homeserver, I access most stuff (containers, updates, etc.) graphically with CasaOS (a web interface), and as a more "casual" PC user, I work with the tools given by my DE. I don't do much fancy stuff.

And when I really need the CLI, fish is alright for me. It's simple, has sane defaults, and feels (thanks to the automatically activated spell check and completion) very efficient for me.

Bash isn't bad, but feels a bit lackluster. Zsh may be better, but requires too much configuration for what it's worth for me.

[–] PseudoSpock@lemmy.dbzer0.com 2 points 1 year ago

You'll want to start toning your skills with Bash and other POSIX shells like AT&T ksh, zsh, and dash if you ever wish to do serious scripting for work... either that, or start learning Python. That is, unless you already have those under your belt. Apology in advance if you already do... I just couldn't understand switching to Fish after already having those skills. If you do, and you then switched to Fish, what was the benefit of that? Just curious.

[–] 12510198@lemmy.blahaj.zone 12 points 1 year ago (1 children)

I designed this prompt shortly after I switched to Linux, I've been using it for a while, it has a few features like putting the exit code if it isn't 0, changing the hostname color if its detected that you are over ssh, changing the directory color to red if it isn't writeable, changing the prompt color to red if your euid is 0, and instead of printing I have no name! when your user does not have an entry in the passwd file, it will just print your uid in red. I also have a version that I wrote in C that works the same way with a subsitution shell, but it was harder to sync across all my devices when I made a change, so I rewrote it in posix shell that could be synced with just my .bashrc and work almost anywhere.

I don't know how to post a screenshot, sorry for the long paragraph, but here is the source code, feel free to share or do whatever with it!

#-----PS1-----#
BOLDRED="\001\033[1;31m\002"
BOLDBLUE="\001\033[1;34m\002"
BOLDPURPLE="\001\033[1;35m\002"
BOLDCYAN="\001\033[1;36m\002"
BOLDGREEN="\001\033[1;32m\002"
COLORRESET="\001\033[0m\002"
CURSOR_BLINK="\001\033[5 q\002"
INFO_COLOR=$BOLDGREEN
SUPERUSER_COLOR=$BOLDRED
NORMALUSER_COLOR=$BOLDCYAN
SSH_COLOR=$BOLDPURPLE
__shellprompt ()
{
        if [ "$(id -u)" = 0 ]; then
                PROMPT_COLOR=$SUPERUSER_COLOR
                PROMPT_EMBLEM='#'
        else
                PROMPT_COLOR=$NORMALUSER_COLOR
                PROMPT_EMBLEM='$'
        fi
        # [user@hostname]
        printf "%b%s%b" "${PROMPT_COLOR}[${INFO_COLOR}" "$(whoami 2>/dev/null || (printf "%b%s" "${BOLDRED}" "UID:$(id -u)"))" "${PROMPT_COLOR}@"
        if [ -n "${SSH_TTY}" ] || [ -n "${SSH_CLIENT}" ]; then
                printf "%b" "$SSH_COLOR"
        else
                printf "%b" "$INFO_COLOR"
        fi
        printf "%s%b" "$(hostname)" "${PROMPT_COLOR}]"
        # :
        printf "%b" "${COLORRESET}:"
        # (/pwd)
        printf "%b" "${PROMPT_COLOR}("
        if [ -w "$PWD" ]; then
                printf "%b" "${INFO_COLOR}"
        else
                printf "%b" "${BOLDRED}"
        fi
        if [ -n "$HOME" ] && [ "$HOME" != "/" ] && { [ "$PWD" = "$HOME" ] || [ "$PWD" != "${PWD#"$HOME/"}" ]; }; then
                printf "%s" "~${PWD#"$HOME"}"
        else
                printf "%s" "${PWD}"
        fi
        printf "%b" "${PROMPT_COLOR})${COLORRESET}"
        # :(EXITCODE)
        if [ "$1" != 0 ]; then
                printf "%b" "${COLORRESET}:"
                printf "%b%s%b" "${PROMPT_COLOR}(${BOLDRED}" "${1}" "${PROMPT_COLOR})${COLORRESET}"
        fi
        # ->$
        # ->#
        printf "%b" "\n${PROMPT_COLOR}->${PROMPT_EMBLEM} ${COLORRESET}${CURSOR_BLINK}"
}
export PS1='$(__shellprompt $?)'
#-----PS1-----#
load more comments (1 replies)
[–] wgs@lemmy.sdf.org 10 points 1 year ago (5 children)

I'm on the boring side...

PS1="% "

I like it though, it gives me more room for commands !

load more comments (5 replies)
[–] netchami@sh.itjust.works 9 points 1 year ago (1 children)

I've been using zsh for some time, but I finally switched to fish. I also checked out Nushell, it lacks some features, but it's really interesting. On zsh I was using Powerlevel10k, on Fish I used oh-my-fish with the shellder theme before I switched to Starship. I'm very happy with this setup. My prompt looks like this:

My Terminal Emulator of choice is kitty, the font is Monocraft.

load more comments (1 replies)
[–] happyhippo@feddit.it 8 points 1 year ago (1 children)

I tried oh-my-bash with some fancy theme, but went back to plain old bash from my distro since suggestions for autocomplete had suddenly started to lag. Went back to default and it's as quick as ever to suggest.

I'm not willing to trade efficiency for bells and whistles

[–] stepanzak@iusearchlinux.fyi 2 points 1 year ago

I don't know about oh-my-bash themes, but on the zsh side, the powerlevel10k can display a lot of information without any lag due to asynchronous implementation. I'm sure there is something similar for bash too.

[–] pete_the_cat@lemmy.world 8 points 1 year ago

I'm old school, I use Bash and do the basic " [user@hostname working-directory]$ " but there's a newline before the first bracket so there's always a line break and an indent after STDOUT so I can tell where the command output ends if it's huge. I also tend to colorize it a bit.

I've tried ZSH and I like it, but as a Linux System Engineering overseeing thousands of servers, they all use Bash, so that's what I've stuck with as well.

[–] Polyester6435@lemmy.blahaj.zone 6 points 1 year ago* (last edited 1 year ago)

Vanilla zsh prompt. I had a thing that told me which git branch I was on for a while but my editor tells me that so I decided I didn't need it

[–] Cwilliams@beehaw.org 6 points 1 year ago

starship.rs on zsh

[–] palordrolap@kbin.social 5 points 1 year ago* (last edited 1 year ago) (1 children)

Standard Bash with a twist:

[ /full/path/~-prefixed where possible ]
 user@short-hostname $ _

(Underscore = cursor, not part of prompt, in case that's not obvious.)

It's similar enough to the most common Bash prompt that I don't feel totally alienated on a different system but different enough to be unique / useful.

The carriage return is deliberate. Paths can often get quite long in my homedir (if not other places), even with the ~ abbreviations. I can't imagine anyone likes starting to type a command more than halfway across a screen because of a long path; this was my solution.

The spacing is deliberate too. The brackets are hard to distinguish without the spaces either side of the path. On the second line, the 1-char indent and the spaces around the obligatory $ were the layout I found most pleasing.

There are embedded colour codes, but it's designed so that it looks fine without them, just in case.

As for other configuration, I use whatever comes with the distro I'm using, especially any command-completion, etc.

load more comments (1 replies)
[–] PseudoSpock@lemmy.dbzer0.com 5 points 1 year ago

Powerline10k with Nerd Fonts, all the way.

[–] 30p87@feddit.de 5 points 1 year ago* (last edited 1 year ago)

As I use bash basically for everything, I wanted my prompt to be as basic as possible (No newlines, fixed format) and compatible across my PC, Laptop as well as server and Pi via SSH.
Therefore, it's a simple __prompt_command function in my .bashrc (nearly) everywhere.
It's structured as:

  1. Terminal/TTY number in orange
  2. Username in green (for roots .bashrc it's red)
  3. Hostname in green
  4. Current working dir in blue
  5. Current git branch in yellow (if in a git repo)
  6. Exit code in red (if not 0)

Looks like this: 1000011281

I used some prompt generator to get the variables and colors right, and then wrapped parts in if-then where needed.
The result is:

__prompt_command() {
    local EXIT="$?"
    PS1="\[\033[38;5;216m\](\l)\[$(tput sgr0)\] \[$(tput sgr0)\]\[\033[38;5;85m\]\u@\H\[$(tput sgr0)\]:\[$(tput sgr0)\]\[\033[38;5;68m\][\w\[$(tput sgr0)\]"
    local GIT_BRANCH="$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/')"
    if ! [[ -z "$GIT_BRANCH" ]]; then
        PS1+=":\[$(tput sgr0)\]\[\033[38;5;142m\]${GIT_BRANCH}\[$(tput sgr0)\]"
    fi
    PS1+="\[\033[38;5;68m\]]\[$(tput sgr0)\]"
    if [ $EXIT != 0 ]; then
        PS1+=":\[$(tput sgr0)\]\[\033[38;5;1m\]${EXIT}\[$(tput sgr0)\]"
    fi
    PS1+="\\$ \[$(tput sgr0)\]"
}

In practice I use every aspect of it. The terminal number is useful for sorting, the username is needed especially when handling e.g. git or db servers with specific users, and one has a terminal as the user, one as root and one as normal user. Hostname is obviously important with multiple ssh sessions open all the time (especially without terminal emulator titles). Typing pwd all the time would be very tedious, as I only move around my system in bash, so having it in the prompt is nice. If I am in a git repo I also need to know the branch and otherwise it's not displayed anyway. Quickly identifying silently failed commands is tedious, especially because issuing one command overwrites $? again, so 'logging' it if necessary is nice.

[–] Drito@sh.itjust.works 5 points 1 year ago (2 children)

I customize the shell prompt in the PS1 variable. Its unpleasant to work with that unreadable language, but I do that once for years and I reuse it across distros.

load more comments (2 replies)
[–] theshatterstone54@feddit.uk 4 points 1 year ago

Currently, I use starship, but I have considered switching to a regular PS1 or similar setup, it's just that I can't get the colours right when using PS1.

[–] acow@programming.dev 4 points 1 year ago

I’ve used powerline-go for a long time now. The modules I use are, modules = ["cwd" "ssh" "dotenv" "nix-shell" "gitlite" "exit"]; (from my home-manager config). It tells me everything I need, and looks pretty, too. Maybe I should mix it up for some variety, but I do like the info it provides.

[–] Presi300@lemmy.world 4 points 1 year ago

Fish shell with a built-in theme

[–] squid@feddit.uk 4 points 1 year ago (2 children)

Bash with blesh captured_image8259805959819673767 And nano-syntax-highlighting captured_image5235261566743949456

load more comments (2 replies)
[–] darcy@sh.itjust.works 4 points 1 year ago

custom, baby! based off starship, but half the latency

[–] vettnerk@lemmy.ml 3 points 1 year ago* (last edited 1 year ago)

I used variations of the same homecooked bash prompt ever since my FreeBSD days 25 years ago, up until Parrotsec made me realize that a prompt doesn't have to be confined to one line.

So now I use:

username@host:/full/path #
:

...with a bunch of colors and special characters to make it more readable at a glance. That colon represents the input line.

To conserve some space I only used last part of CWD before, but now that it's multiline I can use the full path, making it easier when I need to copy-paste an scp-friendly path, as I'm usually working across a bunch of different usernames and hosts.

[–] owsei@lemmy.world 3 points 1 year ago

I made two go programas to make my prompt

It's a pwd with user customization, like colors and names, an inline git status and then the exit code of the last command

inline git status

customizable pwd

I'm in the process of remaking them tho, since they used a shitty go preprocessor that I no longer maintain.

[–] sebastiancarlos@lemmy.sdf.org 3 points 1 year ago (1 children)

.bashrc:

# Prompt
# "Make it simple, just the dollar sign"
# "Say no more, fam"
# - if error code is not 0, then prepend [N] where N is the error code
# - if user is root, use red and #
blue='\e[34m'
red='\e[31m'
bold='\e[1m'
reset='\e[0m'
PS1='$( status=$?; [ $status -ne 0 ] && echo "[$status] ")\['"$blue""$bold"'\]$\['"$reset"'\] '

if [[ $EUID -eq 0 ]]; then
  PS1='$( status=$?; [ $status -ne 0 ] && echo "[$status] ")\['"$red""$bold"'\]#\['"$reset"'\] '
fi

.inputrc:

# vi mode, change to 'emacs' here if you prefer
set editing-mode vi

# vi INSERT prompt
set vi-ins-mode-string "\1\e[30;44m\2 INS \1\e[0m\2 "

# vi NORMAL prompt
set vi-cmd-mode-string "\1\e[30;47m\2 NOR \1\e[0m\2 "
[–] stepanzak@iusearchlinux.fyi 2 points 1 year ago (1 children)

Thanks for sharing! Vi mode ftw 😎

[–] sebastiancarlos@lemmy.sdf.org 2 points 1 year ago

Yes! I use it all the time. No idea why it's not more popular

[–] matejc@matejc.com 2 points 1 year ago

Zsh and Starship.rs on top with few extra minor things. I like my shell fast and clean.

[–] fhein@lemmy.world 2 points 1 year ago (1 children)

zsh with prezto and default prompt. I've customized a bit, but the only change I made to the prompt was to replace "..." (three periods) with "…" (ellipsis unicode) since that makes it more compact with a monospace font. I really like the async loading of git status, so I don't have to wait for the command to run before the prompt prints.

[–] magikmw@lemm.ee 5 points 1 year ago (1 children)

Man, yet another visual/customization tool with not a single screenshot in Readme. Smh

load more comments (1 replies)
[–] Pixel@lemmy.sdf.org 2 points 1 year ago

I used to color my prompt depending on which server I was connected to (ssh), and a different color scheme for prod, dev and local. But that was a long time ago and the script is buried somewhere, also I don't stay ssh'd to nearly as many places as I did back then. But I did like it, I'd use it now if I had it.

[–] mikesailin@lemmy.ml 2 points 1 year ago

Color green for normal users and red for root. then date, hostname. and finally time of day

[–] snowcatridge10@beehaw.org 2 points 1 year ago
[–] rutrum@lm.paradisus.day 2 points 1 year ago* (last edited 1 year ago)

When I hopped on the home manager train I enabled starship (since it was just a couple lines to add) and I'm very happy with it. It has a couple small things out of the box that I really want. Mostly, its trimming my path so it doesnt take the full width of my terminal. I have it set so it only prints the lowest 3 directories and it wont print any directory higher than the current git repo Im in. IMO i hate all the little emojis but that was very easy to remove/disable. Its a very clean experience, and straightforward config (toml if not using nix).

EDIT: here's a pic of the path trimming. This is about as complicated as it gets. Also, I'm using catpuccin color scheme in urxvt.

[–] z3rOR0ne@lemmy.ml 2 points 1 year ago* (last edited 1 year ago)

Custom PROMPT variable in my .zshrc. Similar format in .bashrc, but uses PS1 instead.

Prompt shows git branch, italics and custom colors/characters. Shows a hanging arrow on a newline (i know, wasted newlines are blasphemy to some, but I like it).

Renders nicely in my custom compiled suckless terminal using monospace font.

PROMPT='%B%F{blue}[  %B%F{white}$(tput sitm)'%1~'$(tput sgr0)$(tput bold)%B%F{blue}]$(tput sitm)$ %B%F{white}$(tput setaf 5)${vcs_info_msg_0_}%B%F$(tput sgr0)$(tput setaf 4)$(tput bold)
└─>%B%F{white} '
[–] esm@beehaw.org 2 points 1 year ago (1 children)

There are two usability tweaks that I would find it hard to live without: (1) red prompt on last-command failure, and (2) highlight what I type, dehighlight output:

Reason for 1 is obvious, 2 is more subtle: it helps my eye scan scrollback and identify what I've typed, which is what I'm scanning for 90% of the time.

Implementations vary, here's how I do it in zsh:

  1. PS1='%(?.%K{cyan}%F{white}.%B%K{red}%F{white})XX%b%k%f %(?.%F{cyan}.%F{red})yyy%k%b%F{yellow}%(!.#.$)%f '. Duplication is evil, but AFAIK necessary because the conditional (error check) is %(? and I highlight both parts of my two-part prompt. Suggestions welcome for removing the duplication.
  2. zle_highlight=("default:fg=white") (on a Solarized Dark term, where the default fg color is light gray. Adjust to fit your needs).
load more comments (1 replies)
load more comments
view more: next ›