Jump to content
V.T. Eric Layton

Custom Bash Prompts

Recommended Posts

securitybreach

Especailly since I don't make any

 

Rofl :hysterical:

Share this post


Link to post
Share on other sites
sunrat

Especailly since I don't make any

Me neither. It's easy on Debian. (sunrat dodges hurled stones). :shifty: :whistling:

 

ps. I love the irony of your incorect speling. :D

Share this post


Link to post
Share on other sites
sunrat

Good one Aryeh. There be some nasty but funny posts there, eg.:

alias rm="echo I\\'m sorry Dave, I\\'m afraid I can\\'t do that"

  • Haha 1

Share this post


Link to post
Share on other sites
V.T. Eric Layton

Wow! 2001. I hadn't even heard of Linux then. ;)

Share this post


Link to post
Share on other sites
crp

Is that the page that had the infamous Snoopy prompt? It left the user with only 1 viewable command line and took up all the memory allocated to the environment space.

Share this post


Link to post
Share on other sites
wa4chq

Reviving the dead....lol

Here's my latest......using ZSH.....I'm also including todays weather.

shell_prompt.png

  • Like 2

Share this post


Link to post
Share on other sites
saturnian

Wow! I like short and simple for my bash prompts:

 

user1[~]$

 

PS1='\[\e[1;32m\]\u[\w]\\$ \[\e[0m\]'

 

bash-prompt.png

  • Like 2

Share this post


Link to post
Share on other sites
V.T. Eric Layton

Hmm... that is short and simple. I'll bet you're a vanilla ice cream type, huh? ;)

  • Like 1

Share this post


Link to post
Share on other sites
wa4chq

lol....the screenshot I posted shows the whole screen including my prompt.....the prompt I'm using is just a single line! lol I included the local weather out of kindness...lol

Edited by wa4chq

Share this post


Link to post
Share on other sites
wa4chq
zsh_propt.png
  • Like 3

Share this post


Link to post
Share on other sites
saturnian

Hmm... that is short and simple. I'll bet you're a vanilla ice cream type, huh? ;)

 

Ha-ha, I don't know. Oh, here's the whole window with my neofetch:

 

konsole-2.png

Edited by saturnian
  • Like 1

Share this post


Link to post
Share on other sites
securitybreach

This is from my work laptop:

 

dpMi5GU.png

  • Like 3
  • +1 1

Share this post


Link to post
Share on other sites
wa4chq
PS1="[%w] $fg[green]%n %~ $fg[white]--> "

prompt.png

Edited by wa4chq

Share this post


Link to post
Share on other sites
saturnian

PS1="[%w] $fg[green]%n %~ $fg[white]--> "

 

Does this work only for ZSH? I tried it here (using BASH) and it gives me this prompt, all in white:

 

[%w] [green]%n %~ [white]-->

  • Like 1

Share this post


Link to post
Share on other sites
securitybreach

Main home rig prompt:

 

792leKF.png

  • Like 1

Share this post


Link to post
Share on other sites
securitybreach

PS1="[%w] $fg[green]%n %~ $fg[white]--> "

 

Does this work only for ZSH? I tried it here (using BASH) and it gives me this prompt, all in white:

 

[%w] [green]%n %~ [white]-->

 

Zsh does not use that syntax in it's config. Here is my ~/.zshrc:

 

# Path to your oh-my-zsh installation.
ZSH=/usr/share/oh-my-zsh/

# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="evan"

# Uncomment the following line to disable bi-weekly auto-update checks.
DISABLE_AUTO_UPDATE="true"

# Uncomment the following line to enable command auto-correction.
ENABLE_CORRECTION="true"

# Uncomment the following line to display red dots whilst waiting for completion.
COMPLETION_WAITING_DOTS="true"

plugins=(git)

# User configuration
export PATH=$HOME/bin:/usr/local/bin:$PATH

ZSH_CACHE_DIR=$HOME/.oh-my-zsh-cache
if [[ ! -d $ZSH_CACHE_DIR ]]; then
mkdir $ZSH_CACHE_DIR
fi

source $ZSH/oh-my-zsh.sh

#Syntax highlighting
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

#Aliases
alias vtop='vtop --theme dark'
alias grep='grep --color=auto'
alias rb='dbus-send --system --print-reply --dest="org.freedesktop.Hal" /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Reboot'
alias pa='yay -Syu'
alias di='di -H -x tmpfs,run'
alias tor='chromium --proxy-server="socks://localhost:9050"'
alias myip='dig +short myip.opendns.com @resolver1.opendns.com'
alias mixer='pulsemixer'
alias mail='neomutt'
alias mkdir='mkdir -pv'
source /usr/share/doc/pkgfile/command-not-found.zsh
export _JAVA_OPTIONS='-Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel'

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
export GEM_HOME=$(ruby -e 'print Gem.user_dir')
source ~/.rvm/scripts/rvm

transfer() { if [ $# -eq 0 ]; then echo -e "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"; return 1; fi
tmpfile=$( mktemp -t transferXXX ); if tty -s; then basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g'); curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile; else curl --progress-bar --upload-file "-" "https://transfer.sh/$1" >> $tmpfile ; fi; cat $tmpfile; rm -f $tmpfile; }

  • Like 1

Share this post


Link to post
Share on other sites
wa4chq

PS1="[%w] $fg[green]%n %~ $fg[white]--> "

 

Does this work only for ZSH? I tried it here (using BASH) and it gives me this prompt, all in white:

 

[%w] [green]%n %~ [white]-->

I believe so, only for zsh. If I try using bash prompts with zsh, they don't work. There are plenty of sites for pimping bash. Here's one...https://www.maketecheasier.com/customise-bash-prompt-linux/

  • Like 1
  • +1 1

Share this post


Link to post
Share on other sites
wa4chq

PS1="[%w] $fg[green]%n %~ $fg[white]--> "

 

Does this work only for ZSH? I tried it here (using BASH) and it gives me this prompt, all in white:

 

[%w] [green]%n %~ [white]-->

 

Zsh does not use that syntax in it's config. Here is my ~/.zshrc:

 

# Path to your oh-my-zsh installation.
ZSH=/usr/share/oh-my-zsh/

# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="evan"

# Uncomment the following line to disable bi-weekly auto-update checks.
DISABLE_AUTO_UPDATE="true"

# Uncomment the following line to enable command auto-correction.
ENABLE_CORRECTION="true"

# Uncomment the following line to display red dots whilst waiting for completion.
COMPLETION_WAITING_DOTS="true"

plugins=(git)

# User configuration
export PATH=$HOME/bin:/usr/local/bin:$PATH

ZSH_CACHE_DIR=$HOME/.oh-my-zsh-cache
if [[ ! -d $ZSH_CACHE_DIR ]]; then
mkdir $ZSH_CACHE_DIR
fi

source $ZSH/oh-my-zsh.sh

#Syntax highlighting
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

#Aliases
alias vtop='vtop --theme dark'
alias grep='grep --color=auto'
alias rb='dbus-send --system --print-reply --dest="org.freedesktop.Hal" /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Reboot'
alias pa='yay -Syu'
alias di='di -H -x tmpfs,run'
alias tor='chromium --proxy-server="socks://localhost:9050"'
alias myip='dig +short myip.opendns.com @resolver1.opendns.com'
alias mixer='pulsemixer'
alias mail='neomutt'
alias mkdir='mkdir -pv'
source /usr/share/doc/pkgfile/command-not-found.zsh
export _JAVA_OPTIONS='-Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel'

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
export GEM_HOME=$(ruby -e 'print Gem.user_dir')
source ~/.rvm/scripts/rvm

transfer() { if [ $# -eq 0 ]; then echo -e "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"; return 1; fi
tmpfile=$( mktemp -t transferXXX ); if tty -s; then basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g'); curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile; else curl --progress-bar --upload-file "-" "https://transfer.sh/$1" >> $tmpfile ; fi; cat $tmpfile; rm -f $tmpfile; }

Nice. I use to use "oh-my-zsh"....pretty slick....lot's of cool prompts to choose from.

vtop.....looks interesting......gotta look into that one.

well, I checked into vtop for MX-18 and Slackware....no dice. Guess I'll settle for nmon or htop.

Edited by wa4chq
  • Like 2

Share this post


Link to post
Share on other sites
abarbarian

XJe9FIj.png

 

http://bashrcgenerator.com/

 

I used the above site to create a new bash prompt. Blue for me as a user and red as root. 

 

😎

Share this post


Link to post
Share on other sites
securitybreach

Nice but why xterm? It's the least customizable prompt there is.  Plus you should switch from bash to zsh, it will make your terminal usage 110% better.

Share this post


Link to post
Share on other sites
abarbarian
2 hours ago, securitybreach said:

Nice but why xterm? It's the least customizable prompt there is.  Plus you should switch from bash to zsh, it will make your terminal usage 110% better.

 

Hmmm I only use the cli a little. This is probably why I have never changed, from the wiki,

 

Quote

Although Zsh is usable out of the box, it is almost certainly not set up the way most users would like to use it. But due to the sheer amount of customization available in Zsh, configuring Zsh can be a daunting and time-consuming experience.

 

An I have looked at other terminals but none of them seemed to offer much extra from xterm. Or the benefits were not large enough for me to do loads of reading up on. I did trial a really fancy one ages ago, I liked the E17 one but it borked on an update, a lot of E17 stuff did back then.

An I did try out Fish and ran it for a while.

 

Like I said I only play with the cli now and then, maybe I'll dive in and change at some point but then again ---- 😎

Share this post


Link to post
Share on other sites
securitybreach

Zsh has lots of benefits including tab completion of commands (with options) and filenames as shown by this quick video I recorded: https://www.youtube.com/watch?v=zt7PNAr9vwI

 

Oh-my-zsh is a framework for zsh which provided a lot of prebuilt themes as shown here: https://github.com/ohmyzsh/ohmyzsh/wiki/themes and a bunch of plugins available as well https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins

 

Just install oh-my-zsh-git from AUR (or via git) and type zsh in a terminal to start zsh and if you want it as your default for terminals, follow this  https://wiki.archlinux.org/index.php/Command-line_shell#Changing_your_default_shell

 

Quote

Advantages that I appreciate:

  1. Much easier prompt definitions. Particularly dynamic/multine prompts.
  2. Right Prompt? Yes, thank you!
  3. Awesome set (more comprehensive than BASH) of Auto Completions are much faster and smarter (e.g. case insensitive completion, smart defaults)
  4. Path Expansion is pure win. (cd /v/w [tab] == cd /var/www)
  5. Path Replacement is pretty cool also.
  6. Spelling Correction (setopt correct) is mighty awesome for me.
  7. oh-my-zsh - Large, community driven framework for all sorts of bells and whistles.
  8. The Zsh Line Editor ... just google it
  9. Key Bindings? Yes, thank you!
  10. Globbing is awesome (Extended, inline, just wow!)

 

 

https://www.quora.com/What-are-the-advantages-and-disadvantages-of-using-zsh-instead-of-bash-or-other-shells?share=1

Share this post


Link to post
Share on other sites
saturnian
14 hours ago, abarbarian said:

XJe9FIj.png

 

http://bashrcgenerator.com/

 

I used the above site to create a new bash prompt. Blue for me as a user and red as root. 

 

😎

 

Nice site! Thanks!

 

13 hours ago, securitybreach said:

Nice but why xterm? It's the least customizable prompt there is.  Plus you should switch from bash to zsh, it will make your terminal usage 110% better.

 

I still haven't bothered to switch from bash to zsh! I think I've done a couple of installations now where the distro's default was zsh and I simply switched it to bash. zsh looks cool, maybe I'll try it out.

 

As for xterm, I rarely use that but I'm not very particular about terminal emulators -- often, I just stick with the default.

 

  • +1 1

Share this post


Link to post
Share on other sites
abarbarian
15 hours ago, securitybreach said:

 

Neat, that looks pretty interesting.

 

I have had a good read up from your links and all over the net. I'll let teh info settle in the grey cell for a while. Interesting. 😎

  • Agree 1

Share this post


Link to post
Share on other sites
abarbarian

Bash $PS1 Generator2.0

 

Just another easy to use prompt modifier. 😎

Share this post


Link to post
Share on other sites
abarbarian

Latest addition to me bash prompt,

 

9IB4RgC.png

 

This is the entry I put in my ./bashrc. Do " source ~/.bashrc " to make the change permanent.

PROMPT_COMMAND="echo -n $(tput  bold) $(tput setaf 6)Put brain in gear befor pressing enter"
#unset PROMPT_COMMAND #use this to go back to normal

When starting out you can use the command in a terminal and fiddle about with it till you get it right with no damage done as it goes away when you close the terminal. Took me quite some time before I could get  colour and bold together. I tried loads of different combinations and eventually found the answer tucked away on some obscure site whose link I have misplaced.

I was originally motivated to pursue this time waster by this site,

 

https://tldp.org/HOWTO/Bash-Prompt-HOWTO/x264.html

 

Next timewaster is to put the warning in red and blinking in my root prompt.

 

😜

  • Agree 1

Share this post


Link to post
Share on other sites
securitybreach
1 hour ago, abarbarian said:

Latest addition to me bash prompt,

 

9IB4RgC.png

 

This is the entry I put in my ./bashrc. Do " source ~/.bashrc " to make the change permanent.


PROMPT_COMMAND="echo -n $(tput  bold) $(tput setaf 6)Put brain in gear befor pressing enter"
#unset PROMPT_COMMAND #use this to go back to normal

When starting out you can use the command in a terminal and fiddle about with it till you get it right with no damage done as it goes away when you close the terminal. Took me quite some time before I could get  colour and bold together. I tried loads of different combinations and eventually found the answer tucked away on some obscure site whose link I have misplaced.

I was originally motivated to pursue this time waster by this site,

 

https://tldp.org/HOWTO/Bash-Prompt-HOWTO/x264.html

 

Next timewaster is to put the warning in red and blinking in my root prompt.

 

😜

 

 

So much easier to do the same thing with Oh-My-Zsh

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...