Skip to content

Instantly share code, notes, and snippets.

@CarlOlson
Last active July 14, 2017 17:46
Show Gist options
  • Save CarlOlson/1c38c64db0b8713a53365dac72c908f5 to your computer and use it in GitHub Desktop.
Save CarlOlson/1c38c64db0b8713a53365dac72c908f5 to your computer and use it in GitHub Desktop.

Forward

This will be the steps to setup my (very opinionated) shell environment. Many things may go wrong (environmental variables, paths, etc), but this could be a great learning opertunity.

Use the man command for help! Man pages are viewed in less, try man less to learn how to navigate them better!

Setup

Install Nix Package Manager

curl https://nixos.org/nix/install | sh

Restart your shell to refresh the environment.

Install Packages

nix-channel --add https://nixos.org/channels/nixpkgs-unstable
nix-channel --update

nix-env -i coreutils zsh oh-my-zsh

Append the following to ~/.zshrc and restart your shell:

if [ -e $HOME/.nix-profile/etc/profile.d/nix.sh ]; then
    . $HOME/.nix-profile/etc/profile.d/nix.sh
fi
export MANPATH="$MANPATH:$NIX_LINK/share/man"

In your terminal preferences, set /bin/zsh to run at startup and restart it.

Edit ~/.zshrc to customize zsh, give it a read.

Theme

The theme I use in zsh is sunrise.

I suggest setting your terminal theme to solarized. Readable themes makes your pair partner happy.

Font

I suggest using Anonymous Pro Bold in terminals (20+ pt) and programming (18+ pt). Large fonts makes your pair partner happy.

About

Zsh

Semi-backwards compatible with Bash, but with much better interactive support.

Community driven framework for managing zsh. Has many themes, plugins, and shortcuts.

Coreutils

The core GNU command line tools. These are shell powertools and make your OSX command line more standardized. Read about them here.

Scripting

Use ~/.zsh_funcs to store functions you write, and ~/.zsh_aliases to store your shell aliases.

Aliases

Here is a helpful function (with completion support) for working with aliases:

# ~/.zsh_funcs

save_alias () {
    cmd=`alias $1`
    echo alias $cmd >> ~/.zsh_aliases
}


_save_alias () {
    temp=`alias | sed -e 's/=.*//'`
    _arguments "1:alias:($temp)"
}

compdef _save_alias save_alias

Here is is an example:

# Alias a commonly used command
$ alias rl='readlink -f'

# Try it out
$ pwd
/Users/Carl

$ rl symlinkDir
/Users/carl/projects/realDir

# Save it for future use
save_alias rl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment