DEV Community

Discussion on: Customising our bash shell

Collapse
 
moopet profile image
Ben Sinclair

I have a few comments:
It's not going to load .bash_profile on a lot of systems, depending on where you are and what you're doing (.bashrc might be used instead).

You don't need to create a file before you edit it (if you leave this step out it's less for people to learn).

It looks like your "Windows version setup" is git configuration - did you paste this in from an article from your blog or something? On Windows it would be using WSL or Cygwin or git bash. I have no experience of the latter, so I don't know what I'm talking about!

If you run clear right at the start, then it makes the screen neat, but it means you miss any warnings or errors that might have appeared as the shell started up.

Why do you want it to beep (tput bel) every time your open a new shell?

What's $dir? in the npm section? It's never defined; is that a placeholder for us to fill in? I'd set it to "$HOME/.npm" or something.

alias='$EDITOR ~/.bashrc ; source ~/.bashrc' sets a variable called alias, which you never use (and it'd be a weird name!) so I think that's missing an alias name. You have this covered in your "profile" section later, anyway.

These files can get pretty long, and it's common to split out things like aliases to another file:

[ -f "$HOME/.bash_aliases" ] && . "$HOME/.bash_aliases"

Recently I've started calling this file .aliases and sharing it between zsh and bash so it works on any of my usual environments. Aliases are rarely shell-specific.

Your "Change prompt" section doesn't do anything with the prompt - it's more like a MOTD section - and it uses variables that aren't available as standard ("${COLOR_BROWN}"). It's a useful bunch of stats for you - I'd put it into a script or function instead so you can call it whenever you want.

Almost all your aliases are Mac-specific. I'd divide them up into Mac-only and portable. You said this is for Windows as well, you can split up with something like this:

case $OSTYPE in 
  linux-gnu)
    alias ls='ls --color --group-directories-first -FhN'
    ;;

  darwin*)
    alias ls='ls -FhG'
  ;;

  *)
    # I guess do whatever Windows needs?
  ;;
esac

You probably shouldn't alias .:

alias .='open -a Finder ./'

This shadows the . (source) command, so you'll no longer be able to do things like . ~/.bash_profile to reload your profile!

Collapse
 
leolanese profile image
Leo Lanese

I really appretiate your feedback, I will be working with it to improve this post.

Collapse
 
leolanese profile image
Leo Lanese

Thanks again. It is updated.
If you have any other suggestion, feel free to make a Pull/Request to the GitHub account: github.com/leolanese/bash_profile.git :)