Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2009-2023 otype

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
49 changes: 31 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,48 @@
# Shell

This is my rather extensive [ZSH](http://www.zsh.org/) configuration.
#### A ZSH configurations via simple plugins.

## Requirements
<p>
<a href="https://github.com/otype/shell/commits/master">
<img src="https://img.shields.io/github/last-commit/otype/shell.svg?style=flat-square&logo=github&logoColor=white" alt="GitHub last commit">
<a href="https://github.com/otype/shell/issues">
<img src="https://img.shields.io/github/issues-raw/otype/shell.svg?style=flat-square&logo=github&logoColor=white" alt="GitHub issues">
<a href="https://github.com/otype/shell/pulls">
<img src="https://img.shields.io/github/issues-pr-raw/otype/shell.svg?style=flat-square&logo=github&logoColor=white" alt="GitHub pull requests">
<a href="https://github.com/otype/shell/LICENSE">
<img src="https://img.shields.io/github/license/otype/shell" alt="LICENSE">
</p>

- [ZSH](http://www.zsh.org/)
- [Oh My ZSH!](https://ohmyz.sh/)
Shell is a pluggable configuration for [ZSH](http://www.zsh.org/). Mainly focusing Linux-based systems (partially also Mac OS X), it provides helpful functions, aliases and PATH definitions for a variety of tools you might be using.

Configurations exist for tools/SDKs like [Android SDK](https://developer.android.com/about/versions/13/setup-sdk#install-sdk), [Docker](https://www.docker.com/), [Emacs](https://www.gnu.org/software/emacs/), [Git](https://git-scm.com/), [Goenv](https://github.com/syndbg/goenv), [powerline](https://github.com/powerline/powerline), [pyenv](https://github.com/pyenv/pyenv), [rbenv](https://github.com/rbenv/rbenv), [Rust](https://www.rust-lang.org/) and [tilix](https://gnunn1.github.io/tilix-web/).

## Getting started
## Installation

1. Fork this repository, then clone it to your laptop:
#### Requirements

git clone git@github.com:otype/shell.git ~/.shell
- [ZSH](http://www.zsh.org/)
- [Oh My ZSH!](https://ohmyz.sh/)

2. Symlink ZSH configuration files:
#### Automatic installer

ln -nsf ~/.shell/zshenv ~/.zshenv
ln -nsf ~/.shell/zshrc ~/.zshrc
ln -nsf ~/.shell/zsh/ ~/.zsh
ln -nsf ~/.shell/zprofile ~/.zprofile
Via install script

3. Modify [zshrc](/zsh/zshrc) and update oh-my-zsh location and theme.
```console
curl -L https://raw.githubusercontent.com/otype/shell/main/bin/install.sh | bash
```

4. Enable the configuration files you need:
## Enable configurations

For example, if you want to enable the homebrew config `~/.zsh/env-available/zshenv-brew`:
Once installed, all configurations can be found in `~/.zsh/env-available/`.

cd ~/.zsh/env-enabled
ln -nsf ../env-available/zshenv-brew
To enable e.g. the Android-SDK config `~/.zsh/env-available/zshenv-android` you just need to symlink the config:

```console
cd ~/.zsh/env-enabled
ln -nsf ../env-available/zshenv-android
```

That's it! Repeat this for any other configuration and restart your terminal session.
Repeat this for any other configuration and restart your terminal session.

_Note: Make sure to check each configuration for sanity and correct paths!_
78 changes: 78 additions & 0 deletions bin/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/usr/bin/env bash

set -e
if [ -z "$SHELL_ROOT" ]; then
export SHELL_ROOT="${HOME}/.shell"
fi

colorize() {
if [ -t 1 ]; then printf "\e[%sm%s\e[m" "$1" "$2"
else echo -n "$2"
fi
}

# Checks for `.shell` file, and suggests to remove it for installing
if [ -d "${SHELL_ROOT}" ]; then
{ echo
colorize 1 "WARNING"
echo ": Can not proceed with installation. Kindly remove the '${SHELL_ROOT}' directory first."
echo
} >&2
exit 1
fi

failed_checkout() {
echo "Failed to git clone $1"
exit -1
}

checkout() {
[ -d "$2" ] || git -c advice.detachedHead=0 clone --branch "$3" --depth 1 "$1" "$2" || failed_checkout "$1"
}

if ! command -v git 1>/dev/null 2>&1; then
echo "shell: Git is not installed, can't continue." >&2
exit 1
fi

# Check ssh authentication if USE_SSH is present
if [ -n "${USE_SSH}" ]; then
if ! command -v ssh 1>/dev/null 2>&1; then
echo "shell: configuration USE_SSH found but ssh is not installed, can't continue." >&2
exit 1
fi

# `ssh -T git@github.com' returns 1 on success
# See https://docs.github.com/en/authentication/connecting-to-github-with-ssh/testing-your-ssh-connection
ssh -T git@github.com 1>/dev/null 2>&1 || EXIT_CODE=$?
if [[ ${EXIT_CODE} != 1 ]]; then
echo "shell: github ssh authentication failed."
echo
echo "In order to use the ssh connection option, you need to have an ssh key set up."
echo "Please generate an ssh key by using ssh-keygen, or follow the instructions at the following URL for more information:"
echo
echo "> https://docs.github.com/en/repositories/creating-and-managing-repositories/troubleshooting-cloning-errors#check-your-ssh-access"
echo
echo "Once you have an ssh key set up, try running the command again."
exit 1
fi
fi

if [ -n "${USE_SSH}" ]; then
GITHUB="git@github.com:"
else
GITHUB="https://github.com/"
fi

checkout "${GITHUB}otype/shell.git" "${SHELL_ROOT}" "${SHELL_GIT_TAG:-main}"

# Link all ZSH configs
echo "shell: Symlink all ZSH configurations"
ln -nsf ${SHELL_ROOT}/zshenv ~/.zshenv
ln -nsf ${SHELL_ROOT}/zshrc ~/.zshrc
ln -nsf ${SHELL_ROOT}/zsh ~/.zsh
ln -nsf ${SHELL_ROOT}/zprofile ~/.zprofile

echo "shell: Installation finished."
echo ""
colorize 1 "Set your default shell to ZSH and restart your shell to activate the configurations"