Skip to content

Instantly share code, notes, and snippets.

Last active July 6, 2019 21:01
Show Gist options
  • Save josh-works/7f2e6c82d22dca6e9fbc029c8b17703d to your computer and use it in GitHub Desktop.
Save josh-works/7f2e6c82d22dca6e9fbc029c8b17703d to your computer and use it in GitHub Desktop.
Make the terminal more usable, common commands

Make your terminal more usable

You're going to spend all day looking at your terminal. Make it be kind to you.

Part 1

Here's a video walk-through of part 1 of this guide:

Play the video


tl;dr stands for "too long; didn't read". It's a great tool, too.

to install, just do

$ brew install tldr

Then try the following commands:

$ tldr cd
$ tldr ls
$ tldr git
$ tldr git add
$ tldr git clone
... you get the idea

Git branch in your prompt, and git tab completion

We'll follow the git tab completion instructions from Learn Enough Git

In your terminal, enter the following commands:

$ curl -o ~/ -OL
$ curl -o ~/.git-completion.bash -OL

Next, chmod the permissions on them, using the following:

$ chmod +x ~/
$ chmod +x ~/.git-completion.bash

OK. You've got what you need. We're now going to edit one more file:

Edit your ~/.bash_profile

The following should be in your ~/.bash_profile file:

If you don't know where or what that file is, no problem.

To find it (or create it), cd to your root directory ($ cd ~ and type ls -la. look through the files that start with .

If a file called .bash_profile is there, great. Open it in atom. If it's not, great, create it and open it in atom.

# if you have other stuff in this file, leave it. Just _add_ the following to the file.

source ~/
PS1='[\W$(__git_ps1 " (%s)")]\$ '
export PROMPT_COMMAND='echo -ne "\033]0;${PWD/#$HOME/~}\007"'
# Tab completion for branch names
source ~/.git-completion.bash

after making these changes (or any changes) to see them take effect, either quit and restart your terminal, or run

$ source ~/.bash_profile

from the command line.

Part 2: Make your prompt be offset-colors (and green-on-black, or whatever you want it to be.)

If you want your prompt to have an off-set color than the rest of your terminal, you can do so.

Here's a video walk-through of the next piece:

play the video

Open up your ~/.bashrc, comment out any exisint references to your PS1 or export PROMPT_COMMAND, and paste in the following:

# the following is random instructiosn from Josh Thompson. Here be dragons
# josh's non-default terminal settings
export PROMPT_COMMAND='echo -ne "\033]0;${PWD/#$HOME/~}\007"'

# from
export LSCOLORS=GxBxhxDxfxhxhxhxhxcxcx
PS1="\[\e[32;40m\][\W$(__git_ps1 " (%s)")]\$\[\e[m\] "

# do you wonder what the heck these crazy characters do? check it out:

And that's it. Run source ~/.bashrc, and you should see the color offsets.

Don't forget to set your terminal background to black, and your text color to white, like so:

color settings

If you do it right, it'll all look like so:

green prompt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment