News for hackers. Stuff that matters.
Re:Customizing Your Shell by bewuethr on Friday April 17, 2020 @11:19AM (#22899760)
Not trying to extract the bad parts here – this looks like a lot of effort went into it and it certainly is useful – but there are a few wrinkles:

  [[ $? ]]
is always true, even if $? is non-zero; it only checks if $? is non-empty. A working check for successful exit status would be (for Bash)

  if (($?)); then
      echo "not successful"
  else
      echo "succesful"
  fi
For prompt configurations: the article hardcodes the "$" sign. A useful feature is to indicate when the user is root by switching to "#"; this can be achieved by escaping the "$".

  $ declare -p PS1
  declare -- PS1="\$ "
  $ sudo bash
  # exit bash
  $
And lastly, the examples should be careful about quoting. This

  function mkcd {
      local target=$1
      mkdir -p $target
      cd $target
  }
breaks when called like

  mkcd 'has space'
because $target expands unquoted. Or

  mkcd '*'
would expand to all files in the directory.

The colour section doesn't mention true colour support; many terminal emulator come with it these days, see https://gist.github.com/XVilka/8346728.

There are no comments on this comment yet.