Re: Pimp your shell - Debian developer tips?
Awesome :D. I took a look at liquidprompt and the article having just seen the email I'm responding to. It'll take a little getting used to, but I'm liking it. I've just been using plain defaults (gnome terminal, bash/dash) here except one customisation of re-enabling the colour prompt to better find it in large output. Thanks for bringing this to my attention! One issue though, the article suggests placing this: ``` # Ensure Gnome Terminal shows the prompt correctly PROMPT_COMMAND='echo -ne "\033]2;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"' PROMPT_COMMAND="history -a; history -c; history -r;$PROMPT_COMMAND" ``` into the .bashrc file, but not where is best to place it (or why it's supposedly needed). Placing it at the end of the file, this results in a prompt like this for me: "${debian_chroot:+($debian_chroot)}lyndon@laptop:~$" which is clearly not right. Placing it just before this block though: ``` if [ "$color_prompt" = yes ]; then PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033> else PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' fi ``` it seems to avoid that bug, but I don't see an immediate difference to not having it at all... On Fri, 2020-09-25 at 21:15 +0300, Otto Kekäläinen wrote: > Hello! > > ma 8. kesäk. 2020 klo 12.04 Arturo Borrero Gonzalez > (art...@debian.org) kirjoitti: > > On 5/27/20 9:06 PM, Otto Kekäläinen wrote: > > > Hello! > > > > > > Do we have Debian devs here who have pimped their shell heavily > > > with custom > > > prompts, colors, command line fonts, shell window title hacks, > > > perhaps using zsh > > > etc? Have you written blogs about you experiences, can you share > > > some good reads > > > (with screenshots) of what you have done? > > > > > > I've read a bit on zsh and powerline and the like, but I am > > > annoyed that all > > > those blog posts are quite superficial and do not mention > > > security, > > > interoperability or performance aspects. Frankly any blog post > > > that recommends > > > cloning random repos or even worse, running wget | sh something > > > gives me chills. > ... > > Take a look at liquidprompt(1). > > > > Is what I use everywhere! > > This turned out to be my favourite tip. I've written about my > experiences and why I love it so much at > https://linuxnatives.net/2020/liquid-prompt in case others are > interested. > > And thanks to Arturo for packaging it and for recently uploading the > latest version of it to Debian unstable! > > - Otto >
Re: Pimp your shell - Debian developer tips?
Hello! ma 8. kesäk. 2020 klo 12.04 Arturo Borrero Gonzalez (art...@debian.org) kirjoitti: > > On 5/27/20 9:06 PM, Otto Kekäläinen wrote: > > Hello! > > > > Do we have Debian devs here who have pimped their shell heavily with custom > > prompts, colors, command line fonts, shell window title hacks, perhaps > > using zsh > > etc? Have you written blogs about you experiences, can you share some good > > reads > > (with screenshots) of what you have done? > > > > I've read a bit on zsh and powerline and the like, but I am annoyed that all > > those blog posts are quite superficial and do not mention security, > > interoperability or performance aspects. Frankly any blog post that > > recommends > > cloning random repos or even worse, running wget | sh something gives me > > chills. ... > Take a look at liquidprompt(1). > > Is what I use everywhere! This turned out to be my favourite tip. I've written about my experiences and why I love it so much at https://linuxnatives.net/2020/liquid-prompt in case others are interested. And thanks to Arturo for packaging it and for recently uploading the latest version of it to Debian unstable! - Otto
Re: Pimp your shell - Debian developer tips?
Sorry for being late to the discussion, but I'd like to share my dotfiles and setup script that I use for my Debian Testing machines. https://salsa.debian.org/samueloph/dotfiles I just updated the README.md to explain the high level of it. In summary, this is what I use to setup vim, atom, i3, bashrc, powerline and my packaging tools. Regards, -- Samuel Henrique
Re: Pimp your shell - Debian developer tips?
Hi! Thanks for all the tips! I have a long todo of programs to test out now. One additional source of great Debian Developer wisdom about command-line terminal app / interpreter / productivity is Jonathan Carter's Debian Package of the Day YouTube videos: https://www.youtube.com/watch?v=v9iwVsV50nk=PLIbuTLE8Wih4pBd8S9UjGDGQQXG4-a6Yw=11 I highly recommend it. The best part with those tips is that they are all just one apt install away :) I also found this post about a handful of new Rust based command-line tools interesting, although none of them are in Debian yet: https://towardsdatascience.com/rust-powered-command-line-utilities-to-increase-your-productivity-eea03a4cf83a - Otto
Re: Pimp your shell - Debian developer tips?
On Vi, 12 iun 20, 00:40:40, Phil Morrell wrote: > On Jo, 04 iun 20, 10:13:06, Michael Shuler wrote: > > For many years, I have taken a different approach; use the default and add > > only a few minor changes. Each stable update, I use /etc/skel/.bashrc and > > edit/add in my little bits. > > for config in ~/.config/bash/*; do source "$config"; done > > That is the entirety of my ~/.bashrc due to [WONTFIX], which allows you > to drop in symlinks, organise overrides and specify ordering. I'm > definitely bookmarking this thread to steal some useful snippets. [...] > [WONTFIX]: https://savannah.gnu.org/support/?108134 That can also go in /etc/bash.bashrc to get rid of ~/.bashrc completely. Unfortunately there is no similar trick available for ~/.bash_logout. Kind regards, Andrei -- http://wiki.debian.org/FAQsFromDebianUser signature.asc Description: PGP signature
Re: Pimp your shell - Debian developer tips?
On Jo, 04 iun 20, 10:13:06, Michael Shuler wrote: > For many years, I have taken a different approach; use the default and add > only a few minor changes. Each stable update, I use /etc/skel/.bashrc and > edit/add in my little bits. for config in ~/.config/bash/*; do source "$config"; done That is the entirety of my ~/.bashrc due to [WONTFIX], which allows you to drop in symlinks, organise overrides and specify ordering. I'm definitely bookmarking this thread to steal some useful snippets. 00_skel -> /etc/skel/.bashrc 10_xdg # alias dig="HOME=~/.config dig" arguments # alias ls='ls --almost-all --color=auto --human-readable' bash# see below git-sh-prompt -> /usr/lib/git-core/git-sh-prompt shortcuts # alias serve='nohup python3 -m http.server &>/dev/null &' ssh # see below ZZ_run # PROMPT_COMMAND='__git_ps1 "'"${PS1%\\*}"'" "\\\$ "' ## ~/.config/bash/bash # allow sudo to use local aliases alias sudo='sudo ' export EDITOR=vim # infinite bash history (currently c. 1MiB) export HISTFILE="$HOME/.local/share/bash_history" export HISTFILESIZE= export HISTSIZE= export HISTTIMEFORMAT='[%F %T] ' # more filetypes like .log.1.gz export LESSCLOSE='/usr/bin/lesspipe %s %s' export LESSOPEN='| /usr/bin/lesspipe %s' export PATH="$HOME/bin:$PATH" shopt -s globstar ## ~/.config/bash/ssh export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" ensure_known_host() { local hostname=$1 local known_hosts=${2:-~/.ssh/known_hosts} ssh-keygen -F "$hostname" -f "$known_hosts" &>/dev/null \ || ssh-keyscan -H -t ecdsa "$hostname" \ | tee --append "$known_hosts" } # hook in a custom git style subcommand ssh() { case $1 in tunnel ) shift while true; do date '+%FT%T' command ssh -R :localhost:22 user@server "$@" done ;; * ) command ssh "$@" ;; esac } [WONTFIX]: https://savannah.gnu.org/support/?108134 signature.asc Description: PGP signature
Re: Pimp your shell - Debian developer tips?
On 5/27/20 9:06 PM, Otto Kekäläinen wrote: > Hello! > > Do we have Debian devs here who have pimped their shell heavily with custom > prompts, colors, command line fonts, shell window title hacks, perhaps using > zsh > etc? Have you written blogs about you experiences, can you share some good > reads > (with screenshots) of what you have done? > > I've read a bit on zsh and powerline and the like, but I am annoyed that all > those blog posts are quite superficial and do not mention security, > interoperability or performance aspects. Frankly any blog post that recommends > cloning random repos or even worse, running wget | sh something gives me > chills. > > Some above average posts are > https://linuxhint.com/install_zsh_shell_ubuntu_1804/ > and https://www.hildeberto.com/2018/02/oh-my-zsh.html > > I'd very much want to read about some more knowledgeable experiences. > > > Tips? > Take a look at liquidprompt(1). Is what I use everywhere! regards.
Re: Pimp your shell - Debian developer tips?
On Jo, 04 iun 20, 10:13:06, Michael Shuler wrote: > On 6/3/20 7:30 PM, Gunnar Wolf wrote: > > Like Paul said in his reply, I also have a "bash monstrosity" as a > > Bash prompt. > > For many years, I have taken a different approach; use the default and add > only a few minor changes. Each stable update, I use /etc/skel/.bashrc and > edit/add in my little bits. +1 While not a developer I'll dare share some my changes as well. At least 'linux' and 'screen' should be added to /etc/skel/.bashrc # set a fancy prompt (non-color, unless we know we "want" color) case "$TERM" in xterm-color|*-256color) color_prompt=yes;; rxvt*) color_prompt=yes;; linux) color_prompt=yes;; screen*) color_prompt=yes;; esac Let's use packages in the distribution whenever possible ;) I don't recall where I got the prompt command from... # add git branch information to avoid commiting to 'master' by mistake if [[ -e /usr/lib/git-core/git-sh-prompt ]]; then . /usr/lib/git-core/git-sh-prompt fi GIT_PS1_SHOWUPSTREAM="verbose" #PROMPT_COMMAND='__git_ps1 "${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00;32m\]" "\[\033[00m\]\n└─> \$ "' PROMPT_COMMAND='__git_ps1 "${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00;32m\]" "\[\033[00m\]\$ "' BTW, I prefer 'W' to 'w' (it's my only change below) :) if [ "$color_prompt" = yes ]; then PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]\$ ' else PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' fi unset color_prompt force_color_prompt '--human-readable' makes for a nicer 'ls -l' in the age of MiB, GiB files. Maybe grep --color should be enabled by default as well? # enable color support of ls and also add handy aliases if [ -x /usr/bin/dircolors ]; then test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" alias ls='ls --color=auto --human-readable' #alias dir='dir --color=auto' #alias vdir='vdir --color=auto' alias grep='grep --color=auto' #alias fgrep='fgrep --color=auto' #alias egrep='egrep --color=auto' fi Hope this is useful to someone, Andrei -- http://wiki.debian.org/FAQsFromDebianUser signature.asc Description: PGP signature
Re: Pimp your shell - Debian developer tips?
Hi, > Do we have Debian devs here who have pimped their shell heavily with > custom prompts, colors, command line fonts, shell window title hacks, > perhaps using zsh etc? Have you written blogs about you experiences, can > you share some good reads (with screenshots) of what you have done? I'm using the grml zsh config. There are some differences to the oh-my-zsh-config: https://unix.stackexchange.com/questions/58319/what-is-the-key-difference-between-grml-zsh-config-and-oh-my-zsh-config I prefer grml because it just works well and I know where the grml people are ;) Bernd -- Bernd ZeimetzDebian GNU/Linux Developer http://bzed.dehttp://www.debian.org GPG Fingerprint: ECA1 E3F2 8E11 2432 D485 DD95 EB36 171A 6FF9 435F
Re: Pimp your shell - Debian developer tips?
Some notes from our defaults at $DAYJOB. I can't take credit for most of this. These were ideas I've picked up from various people along the way. # Prevent users from accidentally overwriting files with redirection. set -o noclobber Warning: While I'm the one that added it, sometimes I don't love "noclobber". # Fix some spelling errors in tab-completions shopt -s cdspell shopt -s dirspell # Allow ** to recurse shopt -s globstar 2> /dev/null # Make globs case-insensitive shopt -s nocaseglob # Tell less to not ring the bell (Q) and pass through color escape # sequences (R). export LESS="QR" # Save and show timestamps in the command history. HISTTIMEFORMAT='%F %T ' We also colorize the hostname, which can act as a subtle hint as to whether you are on the right system. (It's basically an subconscious thing; it's not like we memorize which system is which color.) These days, the per-host color is calculated with Jinja templating in Ansible. The example below is the older code where bash calculates it. My email client is going to word-wrap this, so you'll have to reverse that, but it's straightforward. # We use dircolors instead of tput to determine which types of terminals # support colors. Otherwise, we can end up with an inconsistency # between bash and ls, et al. For example: a vt100 on OpenIndiana. if (LS_COLORS= ; eval $(dircolors 2> /dev/null) ; [ -n "$LS_COLORS" ]) then # Colorize based on hostname: green, yellow, blue, magenta, or cyan. ps_h='\[\e[1;'$((32 + $(hostname | cut -d. -f1 | cksum | cut -c1-3) % 5))'m\]\h\[\e[0m\]' if [ "$(id -u)" = "0" ] then # Make the username and # red when logged in as root. PS1='${debian_chroot:+($debian_chroot)}\[\e[1;31m\]\u\[\e[0m\]@'$ps_h':\w\[\e[0;31m\]\$\[\e[0m\] ' else PS1='${debian_chroot:+($debian_chroot)}\u@'$ps_h':\w\$ ' fi unset ps_h if [ -r ~/.dircolors ] then eval "$(dircolors -b ~/.dircolors)" else eval "$(dircolors -b)" fi alias ls='ls --color=auto' alias grep='grep --color=auto' alias fgrep='fgrep --color=auto' alias egrep='egrep --color=auto' else PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' fi It's not shown in the example above, but we also use white text on a red background for the hostname if it ends in -new. This is our convention when a new system is being setup: we set the hostname (in Ansible in our case) for a system replacing a host named "name" to "name-new". This prompt helps you keep track of whether you are on the current production system or the -new system you are configuring. It is functionally equalivalent to: ps_h='\[\e[1;37m\]\[\e[1;41m\]\h\[\e[0m\]' -- Richard signature.asc Description: OpenPGP digital signature
Re: Pimp your shell - Debian developer tips?
On 6/3/20 7:30 PM, Gunnar Wolf wrote: Like Paul said in his reply, I also have a "bash monstrosity" as a Bash prompt. For many years, I have taken a different approach; use the default and add only a few minor changes. Each stable update, I use /etc/skel/.bashrc and edit/add in my little bits. Other than uncommenting a few existing color & alias configs in the default file, I configure history to allow .bash_history grep from any open shell session, and keep a lot more: # save every command, as opposed to only at the end of the session export PROMPT_COMMAND='history -a' # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) HISTSIZE=2 HISTFILESIZE=4 # Useful to know where we stand while using different version control systems parse_git_branch() { # Yes, temporary, dirty, yada yada yada. Works for me™. # --exclude-standard does not exist on git <= 1.5 git_opts='--exclude-standard' branch=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'` if [ ! -z "$branch" ] then clean=`git status --porcelain` if [ ! -z "$clean" ] then branch="${branch}*" new=`git ls-files -o $git_opts|wc -l` del=`git ls-files -d $git_opts|wc -l` mod=$(( `git ls-files -m $git_opts|wc -l` - $del )) if [ $mod != 0 ]; then branch="${branch}${mod}M"; fi if [ $new != 0 ]; then branch="${branch}${new}N"; fi if [ $del != 0 ]; then branch="${branch}${del}D"; fi fi fi echo $branch } Gunnar's git branch foo is what really lead me to post my default .bashrc change strategy. I also depend on knowing branch name and repo status state and use this PS1 config: # adapted from http://people.planetpostgresql.org/dfetter/index.php?/archives/53-Git-+-bash-win.html # https://web.archive.org/web/2016101348/http://www.bramschoenmakers.nl/en/node/624 if [ -f /usr/bin/git ]; then export GIT_PS1_SHOWDIRTYSTATE=1 PSGIT='\[\033[01;31m\]$(__git_ps1 "(%s)")\[\033[00m\]' PS1="$PSGIT$PS1" fi -- Kind regards, Michael
Re: Pimp your shell - Debian developer tips?
On Wed, May 27, 2020 at 10:06:29PM +0300, Otto Kekäläinen wrote: > Hello! > > Do we have Debian devs here who have pimped their shell heavily with custom > prompts, colors, command line fonts, shell window title hacks, perhaps > using zsh etc? Have you written blogs about you experiences, can you share > some good reads (with screenshots) of what you have done? > > I've read a bit on zsh and powerline and the like, but I am annoyed that > all those blog posts are quite superficial and do not mention security, > interoperability or performance aspects. Frankly any blog post that > recommends cloning random repos or even worse, running wget | sh something > gives me chills. > > Some above average posts are > https://linuxhint.com/install_zsh_shell_ubuntu_1804/ and > https://www.hildeberto.com/2018/02/oh-my-zsh.html > > I'd very much want to read about some more knowledgeable experiences. > > > Tips? > Not so much _pimping your existing shell_, but I'd like to give a shout-out for `xonsh` (which I maintain). It's a python shell - think IPython, but with first-class support for running commands and passing pipes and arguments back-and-forth to the python environment. ``` for dctrl in pg`**/debian/control`: head -n1 @(dctrl.parent / "changelog") sv = $(grep-dctrl -n -s Standards-Version . @(dctrl)).strip() if sv != "4.5.0": print(f"old s-v {sv}") ``` It's still admittedly a bit rough round the edges sometimes, and being python there is a memory and performance penalty compared to bash/zsh/fish/whatever, but I find being able to do flow control and string manipulation without shell arcana is very useful (and to answer the original question, the prompt and footer is fully customisable either with builtin placeholders or the output of arbitrary python functions). Gordon [1]: https://xon.sh/ > > Some might react that bells and whistles is useless and real unix beards > only run plain bash, but I think that good text prompts have a potential to > increase productivity. And anyway I don't want those MacOS users to claim > that their shells would be in any way better than what I can have in Debian > ;)
Re: Pimp your shell - Debian developer tips?
On Wed, Jun 03, 2020 at 07:30:01PM -0500, Gunnar Wolf wrote: > Hello world, > > Like Paul said in his reply, I also have a "bash monstrosity" as a > Bash prompt. I last spent time tweaking it many years ago, so... This > migh reflect what my head was like in the past, not today :-] > > I am attaching here the relevant portion of my .bashrc > > > Basically the only improvements over lesser distributions we have are: > > * color: it's not for mere looks, but it visually separates output of > > commands between themselves > > * full path from ~ (Fedora has only the last component which sucks) > > I do consider this to be very important for me. I'm not inlining it > here, as mine is quite verbose, but the colors are defined in > promptFunc(). I don't really follow what you mean by "full path from > ~" — Isn't it what \w produces? Yes, and there are some distributions that use \W, not \w, in their default prompt, and there are lots of people Out There(tm) who do not even realize that \w is an option :) G'luck, Peter -- Peter Pentchev r...@ringlet.net r...@debian.org p...@storpool.com PGP key:http://people.FreeBSD.org/~roam/roam.key.asc Key fingerprint 2EE7 A7A5 17FC 124C F115 C354 651E EFB0 2527 DF13 signature.asc Description: PGP signature
Re: Pimp your shell - Debian developer tips?
Hi Otto, On 5/27/20 9:06 PM, Otto Kekäläinen wrote: > Do we have Debian devs here who have pimped their shell heavily with custom > prompts, colors, command line fonts, shell window title hacks, perhaps > using zsh etc? Have you written blogs about you experiences, can you share > some good reads (with screenshots) of what you have done? I'd like to share my solution to using my zsh environment/customization while switching to root but without polluting root's configuration (or any other user for that matter). I have a function to call a sudo that runs a zsh shell (ignoring root login shell) configured to use my config files instead of root: s () { sudo -u "${1:-root}" -H "ZDOTDIR=${HOME}" -s /bin/zsh } Additionally to that, I have a section in my .zshrc that detect being called as another user and setup aliases for my most used commands to be called with rc files from my user: # We got call as another user, let's setup our env if [ -n "${ZDOTDIR}" ]; then alias vim="vim -u ${ZDOTDIR}/.vimrc" alias vimdiff="vimdiff -u ${ZDOTDIR}/.vimrc" alias git="HOME=${ZDOTDIR} git" alias htop="HTOPRC=${ZDOTDIR}/.config/htop/htoprc htop" alias t="tmux a || tmux -f <(cat ${ZDOTDIR}/.tmux.conf; echo set -g default-shell /bin/zsh)" if [ -f "${ZDOTDIR}/.ssh/config" ]; then alias ssh="ssh -F ${ZDOTDIR}/.ssh/config" alias rsync="rsync -e \"ssh -F ${ZDOTDIR}/.ssh/config\"" fi export SSH_AUTH_SOCK="$(grep -z SSH_AUTH_SOCK /proc/$(ps -p ${PPID} --format=ppid --no-headers)/environ -a 2> /dev/null| cut -d = -f 2)" export EDITOR="vim -u ${ZDOTDIR}/.vimrc" [ -f "${ZDOTDIR}/.identity" ] && source "${ZDOTDIR}/.identity" export GNUPGHOME="${ZDOTDIR}/.gnupg" fi In practice, I can `s` or `s postgres` to switch to root or postgres user continuing to use my config, without polluting user's config. Obviously, unix permisson apply and restrict what you can read/do when switching to another user beside root. -- Baptiste BEAUPLAT - lyknode signature.asc Description: OpenPGP digital signature
Re: Pimp your shell - Debian developer tips?
Hi Otto, On Wed, May 27, 2020 at 10:06:29PM +0300, Otto Kekäläinen wrote: > Do we have Debian devs here who have pimped their shell heavily with custom > prompts, colors, command line fonts, shell window title hacks, perhaps using > zsh etc? Have you written blogs about you experiences, can you share some good > reads (with screenshots) of what you have done? I'm possibly the laziest guy among people who replied to this thread. I used to heavily customize my bash prompt when I was a bash user. But immediately after my discovery of fish shell (apt install fish), I was inclined to choose a extremely simple prompt, by just clicking the favorite prompt theme in fish's GUI config. ~ ❯❯❯ ^ This is the "Sorin" prompt theme of fish. My zsh prompt is basically same, with an additional right side clock: PROMPT="%F{cyan}%~%f %F{red}❯%F{yellow}❯%F{green}❯%F{cyan}❯%f%b " RPROMPT="%B%(?..%F{red}[%?]%f )%F{magenta}%*%f" Personally I dislike tinkering the prompt alot, because IMHO some other features such as "syntax highlighting" and "automatic suggestion" are more important and useful for productivity. TBH I'm a fish user exactly due to the two features. When I have to use a POSIX shell, I'll choose zsh and use the following two plugins: zsh-autosuggestions zsh-syntax-highlighting > I've read a bit on zsh and powerline and the like, but I am annoyed that all > those blog posts are quite superficial and do not mention security, > interoperability or performance aspects. Frankly any blog post that recommends > cloning random repos or even worse, running wget | sh something gives me > chills. I don't worry about security. All the features I want can be installed via apt. I'm also the uploader of some of them. On the other hand, things like oh-my-zsh are too heavy to me, since I only rely on highlighting and autosuggestion.
Re: Pimp your shell - Debian developer tips?
Hello world, Like Paul said in his reply, I also have a "bash monstrosity" as a Bash prompt. I last spent time tweaking it many years ago, so... This migh reflect what my head was like in the past, not today :-] I am attaching here the relevant portion of my .bashrc > Basically the only improvements over lesser distributions we have are: > * color: it's not for mere looks, but it visually separates output of > commands between themselves > * full path from ~ (Fedora has only the last component which sucks) I do consider this to be very important for me. I'm not inlining it here, as mine is quite verbose, but the colors are defined in promptFunc(). I don't really follow what you mean by "full path from ~" — Isn't it what \w produces? > I would like to add at minimum: > * current git branch (but not -dirty as that can take ages on large repos > on slow media -- you want changing directory to be instant) Yes, I have all this set. I remember it being somewhat slow on large repos, but I seldom notice it anymore (and on an SSD, it's seldom more than a couple of seconds on a large Git tree that's not cached). Today I see this as a heavy number of calls to git, and it always calls git even if not in a git tree, but... Whatever ☺ This is defined in parse_git_branch() > * result of the last command Yes, I find this to be tremendously useful. I don't absolutely like the way I handle this (see LAST_RET at the beginning of prompt_func) > Also, for people who use _many_ terminal tabs while logged on to _many_ > machines like me, I'd also suggest window title. To simplify the code I've > personally added parsing this sequence to Linux kernel (as of 3.16). > I also put the title in ALL UPPERCASE if it's a root session, this helps > while doing admin tasks. There's no space for username so I give only > machine name. Makes sense. My window title was meant to reflect the previous command run. But it reflects the last command that _finished_, amd that's not always immediate. I also print my regular username in green, but a root login is presented in red (not only due to the '$' vs. '#' component). > > I've read a bit on zsh and powerline and the like, but I am annoyed that > > all those blog posts are quite superficial and do not mention security, > > interoperability or performance aspects. Frankly any blog post that > > recommends cloning random repos or even worse, running wget | sh something > > gives me chills. > > Aye. Just bash in bashrc should be enough, without iffy Python daemons or > similar stuff. I agree. The code I'm sharing here is far from optimal, but it's easy to follow (after... 5-10 years from its last modification. > As for powerline: it's not in Unicode, and even worse, illegally uses code > points that have since been assigned for something else. Another version of > powerline uses PUA characters, but also with ill-chosen codepoints that > clash with popular assignments (CSUR, MUFI). I'm not aware of Powerline, so I won't comment on it. > Another thing I've tried but rejected is writing some stuff on the right > edge of the screen. This is easy to code and looks good, but causes nasty > unaligned leftovers if you paste pieces of your console that include the > prompt, with you not noticing until after the paste is done. Agree completely. So, without further ado, my prompt follows: # If not running interactively, don't do anything [ -z "$PS1" ] && return # Useful to know where we stand while using different version control systems parse_git_branch() { # Yes, temporary, dirty, yada yada yada. Works for me™. # --exclude-standard does not exist on git <= 1.5 git_opts='--exclude-standard' branch=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'` if [ ! -z "$branch" ] then clean=`git status --porcelain` if [ ! -z "$clean" ] then branch="${branch}*" new=`git ls-files -o $git_opts|wc -l` del=`git ls-files -d $git_opts|wc -l` mod=$(( `git ls-files -m $git_opts|wc -l` - $del )) if [ $mod != 0 ]; then branch="${branch}${mod}M"; fi if [ $new != 0 ]; then branch="${branch}${new}N"; fi if [ $del != 0 ]; then branch="${branch}${del}D"; fi fi fi echo $branch } # set a fancy prompt (non-color, unless we know we "want" color) promptFunc() { LAST_RESULT="$?:$_" LAST_RET=${LAST_RESULT/:*/} LAST_CMD=${LAST_RESULT/*:/} VC_STATUS=`parse_git_branch` case "$TERM" in screen*|xterm*|rxvt*) COLOR_RED="\[\e[31;40m\]" COLOR_GREEN="\[\e[32;40m\]" COLOR_YELLOW="\[\e[33;40m\]" COLOR_BLUE="\[\e[34;40m\]" COLOR_MAGENTA="\[\e[35;40m\]" COLOR_CYAN="\[\e[36;40m\]" COLOR_RED_BOLD="\[\e[31;1m\]" COLOR_GREEN_BOLD="\[\e[32;1m\]" COLOR_YELLOW_BOLD="\[\e[33;1m\]" COLOR_BLUE_BOLD="\[\e[34;1m\]"
Re: Pimp your shell - Debian developer tips?
On Wed, May 27, 2020 at 8:00 PM Adam Borowski wrote: > I would like to add at minimum: > * current git branch (but not -dirty as that can take ages on large repos > on slow media -- you want changing directory to be instant) The standard git prompt stuff supports turning each part off individually: $ cat ~/.bash.d/vcs source /usr/lib/git-core/git-sh-prompt GIT_PS1_SHOWDIRTYSTATE=true GIT_PS1_SHOWSTASHSTATE=true GIT_PS1_SHOWUNTRACKEDFILES=true GIT_PS1_SHOWUPSTREAM="auto verbose" GIT_PS1_SHOWUPSTREAM=auto GIT_PS1_SHOWCOLORHINTS=true GIT_PS1_DESCRIBE_STYLE=branch > * result of the last command I wrote the attached bash monstrosity with the help of a few folks. It is buggy in a few ways but works for me (including for PIPESTATUS). It also enables the standard git prompt stuff and does some other things. -- bye, pabs https://wiki.debian.org/PaulWise z_prompt Description: Binary data
Re: Pimp your shell - Debian developer tips?
On 5/27/20 9:06 PM, Otto Kekäläinen wrote: > Hello! > > Do we have Debian devs here who have pimped their shell heavily with custom > prompts, colors, command line fonts, shell window title hacks, perhaps > using zsh etc? Have you written blogs about you experiences, can you share > some good reads (with screenshots) of what you have done? > > I've read a bit on zsh and powerline and the like, but I am annoyed that > all those blog posts are quite superficial and do not mention security, > interoperability or performance aspects. Frankly any blog post that > recommends cloning random repos or even worse, running wget | sh something > gives me chills. > > Some above average posts are > https://linuxhint.com/install_zsh_shell_ubuntu_1804/ and > https://www.hildeberto.com/2018/02/oh-my-zsh.html > > I'd very much want to read about some more knowledgeable experiences. > > > Tips? > > > Some might react that bells and whistles is useless and real unix beards > only run plain bash, but I think that good text prompts have a potential to > increase productivity. And anyway I don't want those MacOS users to claim > that their shells would be in any way better than what I can have in Debian > ;) > That's an interesting topic. In general I am pretty happy with this config: https://salsa.debian.org/mestia/debbuildenv It uses screen + zsh and color themes are adjusted for a bright terminal. I use screen on the primary console on my work workstation and ssh from it to all other machines which usually have plain bash. If I need a session for something more advanced I start screen with the same config on the remote machine, but keep separate terminal window, so I don't get the nested screens from the "primary" screen terminal. oh-my-zsh looks too heavvy for me. The main reason to use zsh in the setup above is the screen's status line. I didn't manage to customize it good enough with bash. Best, Alex
Re: Pimp your shell - Debian developer tips?
On Wed, May 27, 2020 at 10:06:29PM +0300, Otto Kekäläinen wrote: > Hello! > > Do we have Debian devs here who have pimped their shell heavily with custom > prompts, colors, command line fonts, shell window title hacks, perhaps > using zsh etc? Have you written blogs about you experiences, can you share > some good reads (with screenshots) of what you have done? I wanted to overhaul our default prompt -- but ENOTUITS. It's primitive, and lacks basic goodies. Basically the only improvements over lesser distributions we have are: * color: it's not for mere looks, but it visually separates output of commands between themselves * full path from ~ (Fedora has only the last component which sucks) I would like to add at minimum: * current git branch (but not -dirty as that can take ages on large repos on slow media -- you want changing directory to be instant) * result of the last command Also, for people who use _many_ terminal tabs while logged on to _many_ machines like me, I'd also suggest window title. To simplify the code I've personally added parsing this sequence to Linux kernel (as of 3.16). I also put the title in ALL UPPERCASE if it's a root session, this helps while doing admin tasks. There's no space for username so I give only machine name. Another thing is machine name in /etc/issue. This might be counterintuitive as it's used only for local sessions -- but the console ignores these sequences so the title shows up only when accessed via serial. > I've read a bit on zsh and powerline and the like, but I am annoyed that > all those blog posts are quite superficial and do not mention security, > interoperability or performance aspects. Frankly any blog post that > recommends cloning random repos or even worse, running wget | sh something > gives me chills. Aye. Just bash in bashrc should be enough, without iffy Python daemons or similar stuff. As for powerline: it's not in Unicode, and even worse, illegally uses code points that have since been assigned for something else. Another version of powerline uses PUA characters, but also with ill-chosen codepoints that clash with popular assignments (CSUR, MUFI). Another thing I've tried but rejected is writing some stuff on the right edge of the screen. This is easy to code and looks good, but causes nasty unaligned leftovers if you paste pieces of your console that include the prompt, with you not noticing until after the paste is done. > Some might react that bells and whistles is useless and real unix beards > only run plain bash, but I think that good text prompts have a potential to > increase productivity. Alas, zsh is a problem if you use many machines and many chroots (which also want to be minimal), or machines not under your control. Thus, bash is the king because it is always there. And it _can_ do everything that powerlevel9k and such toys do, without performance problems. Thus: my /etc/issue is: \e]0;⭍\n\e\\Debian GNU/Linux \n \l \n unobviously means the machine's mode, ⭍ is my marker for serial consoles. These sequences before the word "Debian" are invisible and go only to a window title if there's one. As for my bashrc, some snippets: # ! has been long obsoleted by ^R and it can cause nasty surprises. set +H # We want less goodness. [ -x /usr/bin/lesspipe ] && eval "$(lesspipe)" if [ -x /usr/bin/git ] then git_branch='$(parse_git_branch)' function parse_git_branch { git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' } fi PROMPT_COMMAND='if ((ERROR=$?)) then if [ "$ERROR" -gt 128 ] then ERRORSIG="$(kill -l $(($ERROR-128)) 2>/dev/null)" [ -n "$ERRORSIG" ] && ERROR="$ERRORSIG" fi PROMPT_ERRORC="0;33;1;41" PROMPT_ERROR="$ERROR" else PROMPT_ERROR="" fi' [ -n "$SCHROOT_CHROOT_NAME" ] && export PS1="\[\e[0;1m\]{$SCHROOT_CHROOT_NAME}\[\e[0m\]@$PS1" # Compat with Hurd console and ancient bash. case "$TERM" in hurd) ;; *) if [ "$UID" == "0" ] then RH=`echo "$HOSTNAME"|tr a-z A-Z` fi if [ -n "${BASH_VERSION/#4.2.*/}" ] then PROMPT_COMMAND+=';echo -ne "\e]0;${SCHROOT_CHROOT_NAME:+{$SCHROOT_CHROOT_NAME\} }${RH:-$HOSTNAME}: ${PWD/#$HOME/\~}\e\\"' else PROMPT_COMMAND+=';echo -ne "\e]0;${SCHROOT_CHROOT_NAME:+{$SCHROOT_CHROOT_NAME\} }${RH:-$HOSTNAME}: ${PWD/#$HOME/~}\e\\"' fi ;; esac # Per-hostname prompts. case "$HOSTNAME" in umbar)PSC1='\e[0;36m';; moria|khazad-dum) PSC1='\e[0;32m';; dimrill|baranzibar|redhorn|zirak-zigil|zirakzigil|silvertine|bundushathur|azanulbizar|mirrormere) PSC1='\e[0;32m' PSH=1;; andunie) PSC1='\e[0;38;5;107m' PSC2='\e[0;1;38;5;193m';; harlond) PSC1='\e[0;1;32m' PSC2='\e[0;32m';; sirius) PSC1='\e[0;38;5;137m' PSC2='\e[0;38;5;223m';; # ... *)PSC1='\e[0;1;31m' PSC2='\e[0;31m' PSH=1;; esac export
Re: Pimp your shell - Debian developer tips?
Le mercredi 27 mai 2020 à 22:06 +0300, Otto Kekäläinen a écrit : > Do we have Debian devs here who have pimped their shell heavily with > custom prompts, colors, command line fonts, shell window title hacks, > perhaps using zsh etc? Have you written blogs about you experiences, > can you share some good reads (with screenshots) of what you have > done? I don't know where I got that one, but I have a "myautopkgtest" script containing only: autopkgtest $1 -- schroot unstable-amd64-sbuild and in my .bashrc : _myautopkgtest() { local cur=${COMP_WORDS[COMP_CWORD]} COMPREPLY=( $( compgen -f -X '!*.dsc' -- $cur ) ) return 0 } complete -F _myautopkgtest myautopkgtest That's a pretty trivial hack, but it does save quite a few keystrokes, when one checks a package before an upload. Cheers, JP
Pimp your shell - Debian developer tips?
Hello! Do we have Debian devs here who have pimped their shell heavily with custom prompts, colors, command line fonts, shell window title hacks, perhaps using zsh etc? Have you written blogs about you experiences, can you share some good reads (with screenshots) of what you have done? I've read a bit on zsh and powerline and the like, but I am annoyed that all those blog posts are quite superficial and do not mention security, interoperability or performance aspects. Frankly any blog post that recommends cloning random repos or even worse, running wget | sh something gives me chills. Some above average posts are https://linuxhint.com/install_zsh_shell_ubuntu_1804/ and https://www.hildeberto.com/2018/02/oh-my-zsh.html I'd very much want to read about some more knowledgeable experiences. Tips? Some might react that bells and whistles is useless and real unix beards only run plain bash, but I think that good text prompts have a potential to increase productivity. And anyway I don't want those MacOS users to claim that their shells would be in any way better than what I can have in Debian ;)