6 points afefers | 4 comments | | HN request time: 0.469s | source

What are the most useful/essential things in your shell configuration file. Be it custom function, wrappers, aliases, etc. Please provide an explanation since it isn't always obvious to others.
1. ◴[] No.41915637[source]
2. ndegruchy ◴[] No.41916096[source]
I have a couple of favorites (bash):

  # Only provide CDPATH when interactive...
  if [[ $- = *i* ]];
  then
      export CDPATH=:"$HOME"/Projects/
  fi
`CDPATH` is great. It's like having z, j or zoxide installed for configurable paths. While it doesn't fully replace the former, it provides a lot of the useful functionality for me.

  _cleanup_files() {    
      # Cleanup files
      local OFFENDERS=(
   "$HOME"/.java
   "$HOME"/.oracle_jre_usage
   "$HOME"/.pki
   "$HOME"/.wget-hsts
   "$HOME"/.xsession-errors
          ...
      )

      for FILE in "${OFFENDERS[@]}";
      do
   if [[ -e "$FILE" ]];
   then
       trash-put "$FILE"
   fi
      done
  }

  # Prompt
  export PROMPT_COMMAND=_cleanup_files

There are certain files that get created from various apps that I run that aren't really useful (font caches, etc). Try as I might, I can't get them into appropriate XDG-style locations. I could wrap them in boxxy, but this seems simpler. I put them in the trash in case something blew up and I need to recover it.
3. withinboredom ◴[] No.41917978[source]
I have `git fsync` which pulls and deletes all the local branches when the remote branch is deleted.

    fsync = !git pull --rebase && git fetch -p && git branch -vv | grep ': gone]' | awk '{print $1}' | xargs git branch -D
This is probably my most-used alias on my machine, by far.