You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
3.9 KiB
84 lines
3.9 KiB
# Aaron's ZSH Config
|
|
|
|
This is the basis of my ZSH config for all of my systems.
|
|
|
|
----------------------
|
|
## Setup
|
|
#### Step 1: Clone this repository
|
|
I personally like to clone this into `~/git/zsh` and use symlinks from there, so that's how I will write this up. If you'd rather, you can just as well clone it straight to `~/.zsh` if you want.
|
|
```
|
|
# If git directory doesn't exist:
|
|
mkdir ~/git
|
|
|
|
git clone https://git.skyfall.tech/ajohnson/zsh.git ~/git/zsh
|
|
|
|
## Or, if you have a valid user on git.skyfall.tech, you can use the SSH connection:
|
|
|
|
git clone git@git.skyfall.tech:ajohnson/zsh.git ~/git/zsh
|
|
```
|
|
#### Step 2: Copy out example config files and edit to your preferences
|
|
Some variables of the shell configuration I don't keep the same across the board, so I have created a `zsh.conf` file for things such as shell options and prompt styles/colours. I have also added a [very] basic "custom" template file as an example as well. Both of these files, once copied to to the repo's root dir, will be ignored by git.
|
|
```
|
|
cd ~/git/zsh
|
|
cp -v example_configs/* ./
|
|
```
|
|
**IMPORTANT:**
|
|
The defaults in zsh/conf will work well for most systems, but if you are using any kind of BSD-derived system, including Mac OS-X, you will definitely need to set `BSD_MODE=true` in zsh.conf.
|
|
#### Step 3: Deploy symlinks to load the configuration
|
|
Even if you opted to clone the repo straight to `~/.zsh`, you will still need to at least make the symlink for the `zshrc` file.
|
|
```
|
|
cd
|
|
ln -s git/zsh .zsh
|
|
ln -s git/zsh/zshrc ./zshrc
|
|
|
|
# Test deployment by opening a new zsh instance
|
|
zsh
|
|
```
|
|
## Customization
|
|
Other than the `zsh.conf` options, you can perform any sort of customization you want easily by placing the configuration in the `custom` file. The `custom` file is loaded last, and so will overwrite anything set up by the default shell configuration here. You can also source other outside files from the `custom` files as well. If you don't care for any of the pre-defined prompts provided, just set up a new on in `custom`!
|
|
## Notable Features
|
|
#### HISTORY_HIDE_SPACE
|
|
This option will let any command starting with an empty space character be omitted from `.zsh_history`. This is very useful for things such as running commands that contain passwords, for instance.
|
|
#### AUTO_CD
|
|
If you just name a path, the shell will assume you intended to change directories.
|
|
```
|
|
ajohnson@helios:~ % git/zsh
|
|
ajohnson@helios:~/git/zsh [add_readme]%
|
|
```
|
|
#### SHOW_NZ_EXIT
|
|
This option will display exit codes of the previous command at the beginning of your prompt, but only when the exit code is non-zero. If the previous command returns 0, then your prompt will not show any exit code.
|
|
```
|
|
ajohnson@helios:~ %
|
|
ajohnson@helios:~ % true
|
|
ajohnson@helios:~ % false
|
|
1:ajohnson@helios:~ %
|
|
1:ajohnson@helios:~ % true
|
|
ajohnson@helios:~ %
|
|
ajohnson@helios:~ % zsh -c "exit 42"
|
|
42:ajohnson@helios:~ %
|
|
```
|
|
#### cd Search and Replace
|
|
You can substitute one word for another in your current working directory by using the cd syntax:
|
|
```
|
|
cd [old_word] [new_word]
|
|
```
|
|
Here is an example where I `cd` from a Confluence Tomcat log dir to a Jira Tomcat log dir, which you can see by looking at the current working directory in the prompt:
|
|
```
|
|
ajohnson@atlas:/opt/j2ee/domains/skyfall.tech/wiki/current/logs % cd wiki jira
|
|
/opt/j2ee/domains/skyfall.tech/jira/current/logs
|
|
ajohnson@atlas:/opt/j2ee/domains/skyfall.tech/jira/current/logs %
|
|
```
|
|
#### Display Current VCS Branch in Prompt
|
|
This feature is my favourite one on the list. It works with Git and Subversion at least, though I have never tested it with Mercurial.
|
|
In this example, I start out in the 'rewrite' branch and switch to 'dev'.
|
|
```
|
|
ajohnson@helios:~/git/heatbot [rewrite]% git checkout dev
|
|
Switched to branch 'dev'
|
|
Your branch is up to date with 'origin/dev'.
|
|
ajohnson@helios:~/git/heatbot [dev]%
|
|
```
|
|
|
|
## Epilogue
|
|
If there are other prompt layouts/styles that you'd like to share, let me know and I'll be happy taking a look and considering adding them as options.
|
|
|