Skip to content

Commit 25f4cc2

Browse files
author
Adam Campbell
authoredSep 10, 2021
Merge pull request #1 from getclair/ohmyzsh-setup
Adds Oh My Zsh setup
2 parents bc0987b + 76c74d6 commit 25f4cc2

14 files changed

+783
-65
lines changed
 

‎app/Commands/HelloCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ class HelloCommand extends Command
2727
protected $steps = [
2828
'install:cli-tools',
2929
'configure',
30-
'install:shell',
3130
'install:apps',
31+
'install:shell',
3232
'install:repos',
3333
];
3434

‎app/Commands/InstallCliToolsCommand.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function handle()
4646

4747
foreach ($selections as $selection) {
4848
$this->task("Installing {$selection['name']}", function () use ($selection) {
49-
if ($this->shouldInstallCliTool($selection['check'])) {
49+
if ($this->shouldInstallCliTool($selection)) {
5050
$this->terminal()->output($this)->run($selection['command']);
5151
}
5252

@@ -105,12 +105,16 @@ protected function buildQuestion()
105105
/**
106106
* Check if a CLI tool should be installed, or if it exists already.
107107
*
108-
* @param $check
108+
* @param array $selection
109109
* @return bool
110110
*/
111-
protected function shouldInstallCliTool($check): bool
111+
protected function shouldInstallCliTool(array $selection): bool
112112
{
113-
$response = $this->terminal()->run($check);
113+
if (! array_key_exists('check', $selection)) {
114+
return true;
115+
}
116+
117+
$response = $this->terminal()->run($selection['check']);
114118

115119
return ! $response->ok()
116120
|| $response->getExitCode() === 1

‎app/Commands/InstallShellCommand.php

+3-12
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ public function handle()
3434
if ($choice !== 'none') {
3535
$config = $options[$choice];
3636

37-
$this->installZsh();
3837
$this->installShell($config);
3938
}
4039
}
@@ -60,23 +59,15 @@ protected function buildQuestion(array $options): string
6059
);
6160
}
6261

63-
/**
64-
* Install zsh.
65-
*/
66-
public function installZsh()
67-
{
68-
if (! $this->terminal()->run('which zsh')->ok()) {
69-
$this->terminal()->output($this)->run('brew install zsh');
70-
}
71-
}
72-
7362
/**
7463
* Install the chosen shell.
7564
*
7665
* @param array $config
7766
*/
7867
public function installShell(array $config)
7968
{
80-
$this->terminal()->output($this)->run($config['command']);
69+
if (! $this->terminal()->run($config['check'])->ok()) {
70+
$this->terminal()->output($this)->run($config['command']);
71+
}
8172
}
8273
}

‎app/Commands/SetupOhMyZsh.php

+157
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
<?php
2+
3+
namespace App\Commands;
4+
5+
use Illuminate\Support\Facades\File;
6+
use ZipArchive;
7+
8+
class SetupOhMyZsh extends StepCommand
9+
{
10+
/**
11+
* The signature of the command.
12+
*
13+
* @var string
14+
*/
15+
protected $signature = 'configure:oh-my-zsh';
16+
17+
/**
18+
* The description of the command.
19+
*
20+
* @var string
21+
*/
22+
protected $description = 'Configure Oh My Zsh.';
23+
24+
protected static $packageName = 'iterm2env';
25+
26+
/**
27+
* Execute the console command.
28+
*
29+
* @return void
30+
*/
31+
public function handle()
32+
{
33+
$this->newLine();
34+
$this->line('Configuring Oh My Zsh...');
35+
$this->newLine();
36+
37+
$tasks = [
38+
[
39+
'description' => 'Adding Zsh theme...',
40+
'source' => resource_path('config/cobalt2-custom.zsh-theme'),
41+
'destination' => $this->homeDirectory('.oh-my-zsh/themes/cobalt2-clair.zsh-theme'),
42+
],
43+
[
44+
'description' => 'Adding iTerm2 theme...',
45+
'source' => resource_path('config/iTerm2-custom.zsh'),
46+
'destination' => $this->homeDirectory('.oh-my-zsh/custom/iTerm2-clair.zsh'),
47+
],
48+
[
49+
'description' => 'Adding .zshrc...',
50+
'source' => resource_path('config/.zshrc'),
51+
'destination' => $this->homeDirectory('/.zshrc-tmp'),
52+
],
53+
[
54+
'description' => 'Configuring shell aliases...',
55+
'command' => "echo 'alias python2=\"/usr/bin/python\"' >> ~/.zshrc && echo 'alias python=\"/usr/local/bin/python3\"' >> ~/.zshrc && source ~/.zshrc",
56+
],
57+
[
58+
'description' => 'Installing Powerline...',
59+
'command' => 'pip3 install iterm2 && pip3 install --user powerline-status && cd ~ && git clone https://github.com/powerline/fonts && cd fonts && ./install.sh && cd ~',
60+
],
61+
[
62+
'description' => 'Configuring iTerm2...',
63+
'source' => resource_path('scripts/default-profile.py'),
64+
'destination' => $this->homeDirectory('/Library/Application Support/iTerm2/Scripts/AutoLaunch/clair-profile.py'),
65+
'method' => 'installiTerm2Python',
66+
],
67+
];
68+
69+
foreach ($tasks as $task) {
70+
$this->task($task['description'], function () use ($task) {
71+
if (array_key_exists('source', $task)) {
72+
File::copy($task['source'], $task['destination']);
73+
}
74+
75+
if (array_key_exists('command', $task)) {
76+
$this->newLine();
77+
$this->terminal()->output($this)->run($task['command']);
78+
}
79+
80+
if (array_key_exists('method', $task) && method_exists($this, $task['method'])) {
81+
$this->newLine();
82+
call_user_func([$this, $task['method']]);
83+
}
84+
85+
return true;
86+
}, '');
87+
}
88+
89+
$this->newLine();
90+
$this->comment('Oh My Zsh successfully configured.');
91+
$this->newLine();
92+
}
93+
94+
protected function installiTerm2Python()
95+
{
96+
// Get manifest...
97+
$this->comment('Downloading package...');
98+
99+
$manifest = json_decode(file_get_contents('https://iterm2.com/downloads/pyenv/manifest.json'), true);
100+
101+
// Download file locally.
102+
$url = $manifest[0]['url'];
103+
104+
$tempFolder = storage_path('tmp');
105+
$path = $tempFolder.'/env.zip';
106+
107+
if (File::isDirectory($tempFolder)) {
108+
File::deleteDirectory($tempFolder);
109+
}
110+
111+
File::makeDirectory($tempFolder);
112+
113+
$remote_file_contents = file_get_contents($url);
114+
115+
file_put_contents($path, $remote_file_contents);
116+
117+
// Unzip
118+
$this->comment('Unzipping package...');
119+
120+
$zipArchive = new ZipArchive();
121+
122+
if ($zipArchive->open($path)) {
123+
$zipArchive->extractTo($tempFolder);
124+
$zipArchive->close();
125+
126+
// Delete the zip file.
127+
File::delete($path);
128+
129+
$sourceFolder = $tempFolder.'/'.static::$packageName;
130+
131+
// Move files.
132+
$versions = $manifest[0]['python_versions'];
133+
$versions[] = '';
134+
135+
foreach ($versions as $version) {
136+
$folder = static::$packageName;
137+
138+
if (strlen($version) > 0) {
139+
$folder .= '-'.$version;
140+
}
141+
142+
$destinationFolder = $this->homeDirectory('Library/ApplicationSupport/iTerm2/'.$folder);
143+
144+
$this->comment("Moving package to: $destinationFolder");
145+
146+
$this->terminal()->output($this)->with([
147+
'source' => $sourceFolder.'/',
148+
'destination' => $destinationFolder,
149+
])->run('rsync --progress --stats --human-readable --recursive --timeout=300 {{ $source }} {{ $destination }}');
150+
}
151+
152+
// Cleanup
153+
$this->comment('Cleaning up...');
154+
File::deleteDirectory($tempFolder);
155+
}
156+
}
157+
}

‎app/Commands/StepCommand.php

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Commands;
44

5+
use Illuminate\Support\Str;
56
use LaravelZero\Framework\Commands\Command;
67
use TitasGailius\Terminal\Terminal;
78

@@ -22,6 +23,10 @@ protected function terminal($context = null)
2223
*/
2324
protected function homeDirectory($path = null): string
2425
{
26+
if (Str::startsWith($path, '/')) {
27+
$path = Str::replaceFirst('/', '', $path);
28+
}
29+
2530
return implode('/', [getenv('HOME'), $path]);
2631
}
2732
}

‎composer.json

+58-47
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,60 @@
11
{
2-
"name": "getclair/hello-clair",
3-
"description": "The Laravel Zero Framework.",
4-
"keywords": ["framework", "laravel", "laravel zero", "console", "cli"],
5-
"type": "project",
6-
"license": "MIT",
7-
"support": {
8-
"source": "https://github.com/getclair/hello-clair"
9-
},
10-
"authors": [
11-
{
12-
"name": "Adam Campbell",
13-
"email": "adam@getclair.com"
14-
}
15-
],
16-
"require": {
17-
"php": "^7.3|^8.0",
18-
"czproject/git-php": "^4.0",
19-
"hotmeteor/eco-env": "^1.1",
20-
"laminas/laminas-text": "^2.8",
21-
"laravel-zero/phar-updater": "^1.0.6",
22-
"nunomaduro/laravel-console-menu": "^3.2",
23-
"nunomaduro/laravel-console-task": "^1.6",
24-
"titasgailius/terminal": "^1.0"
25-
},
26-
"require-dev": {
27-
"laravel-zero/framework": "^8.8",
28-
"mockery/mockery": "^1.4.3",
29-
"pestphp/pest": "^1.3"
30-
},
31-
"autoload": {
32-
"psr-4": {
33-
"App\\": "app/"
34-
}
35-
},
36-
"autoload-dev": {
37-
"psr-4": {
38-
"Tests\\": "tests/"
39-
}
40-
},
41-
"config": {
42-
"preferred-install": "dist",
43-
"sort-packages": true,
44-
"optimize-autoloader": true
45-
},
46-
"minimum-stability": "dev",
47-
"prefer-stable": true,
48-
"bin": ["builds/clair"]
2+
"name": "getclair/hello-clair",
3+
"description": "The Laravel Zero Framework.",
4+
"keywords": [
5+
"framework",
6+
"laravel",
7+
"laravel zero",
8+
"console",
9+
"cli"
10+
],
11+
"type": "project",
12+
"license": "MIT",
13+
"support": {
14+
"source": "https://github.com/getclair/hello-clair"
15+
},
16+
"authors": [
17+
{
18+
"name": "Adam Campbell",
19+
"email": "adam@getclair.com"
20+
}
21+
],
22+
"require": {
23+
"php": "^7.3|^8.0",
24+
"ext-curl": "*",
25+
"ext-json": "*",
26+
"ext-zip": "*",
27+
"czproject/git-php": "^4.0",
28+
"hotmeteor/eco-env": "^1.1",
29+
"laminas/laminas-text": "^2.8",
30+
"laravel-zero/phar-updater": "^1.0.6",
31+
"nunomaduro/laravel-console-menu": "^3.2",
32+
"nunomaduro/laravel-console-task": "^1.6",
33+
"titasgailius/terminal": "^1.0"
34+
},
35+
"require-dev": {
36+
"laravel-zero/framework": "^8.8",
37+
"mockery/mockery": "^1.4.3",
38+
"pestphp/pest": "^1.3"
39+
},
40+
"autoload": {
41+
"psr-4": {
42+
"App\\": "app/"
43+
}
44+
},
45+
"autoload-dev": {
46+
"psr-4": {
47+
"Tests\\": "tests/"
48+
}
49+
},
50+
"config": {
51+
"preferred-install": "dist",
52+
"sort-packages": true,
53+
"optimize-autoloader": true
54+
},
55+
"minimum-stability": "dev",
56+
"prefer-stable": true,
57+
"bin": [
58+
"builds/clair"
59+
]
4960
}

‎config/manifest.php

+16-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@
6969
'command' => 'brew install php',
7070
],
7171

72+
'python' => [
73+
'name' => 'Python',
74+
'description' => 'Installing Python...',
75+
'check' => 'which python3',
76+
'command' => 'brew install python3',
77+
],
78+
7279
'composer' => [
7380
'name' => 'Composer',
7481
'description' => '',
@@ -83,6 +90,12 @@
8390
'command' => 'composer global require laravel/valet && valet domain test',
8491
],
8592

93+
'redis' => [
94+
'name' => 'Redis',
95+
'description' => '',
96+
'command' => 'yes | pecl install -f redis',
97+
],
98+
8699
],
87100

88101
'frontend' => [
@@ -120,13 +133,15 @@
120133
'name' => 'Oh My Zsh',
121134
'description' => 'Oh My Zsh is an open source, community-driven framework for managing your zsh configuration. It comes with a bunch of features out of the box and improves your terminal experience.',
122135
'url' => 'https://github.com/robbyrussell/oh-my-zsh',
123-
'command' => 'sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"',
136+
'check' => 'which zsh',
137+
'command' => 'sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" && clair configure:oh-my-zsh',
124138
],
125139

126140
'prezto' => [
127141
'name' => 'Prezto',
128142
'description' => 'Prezto is a configuration framework for zsh; it enriches the command line interface environment with sane defaults, aliases, functions, auto completion, and prompt themes.',
129143
'url' => 'https://github.com/sorin-ionescu/prezto',
144+
'check' => 'which prezto',
130145
'command' => '
131146
git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto" && \
132147
setopt EXTENDED_GLOB \

‎resources/config/.zshrc

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
ZSH_DISABLE_COMPFIX=true
2+
# If you come from bash you might have to change your $PATH.
3+
# export PATH=$HOME/bin:/usr/local/bin:$PATH
4+
5+
# Path to your oh-my-zsh installation.
6+
export ZSH=~/.oh-my-zsh
7+
8+
# Set name of the theme to load. Optionally, if you set this to "random"
9+
# it'll load a random theme each time that oh-my-zsh is loaded.
10+
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
11+
# ZSH_THEME="robbyrussell"
12+
#
13+
14+
sudo cp ~/server-setup/cobalt2-custom.zsh-theme ~/.oh-my-zsh/themes/
15+
sudo cp ~/server-setup/iTerm2-custom.zsh ~/.oh-my-zsh/custom/
16+
17+
ZSH_THEME="cobalt2-custom"
18+
19+
# Uncomment the following line to use case-sensitive completion.
20+
# CASE_SENSITIVE="true"
21+
22+
# Uncomment the following line to use hyphen-insensitive completion. Case
23+
# sensitive completion must be off. _ and - will be interchangeable.
24+
# HYPHEN_INSENSITIVE="true"
25+
26+
# Uncomment the following line to disable bi-weekly auto-update checks.
27+
# DISABLE_AUTO_UPDATE="true"
28+
29+
# Uncomment the following line to change how often to auto-update (in days).
30+
# export UPDATE_ZSH_DAYS=13
31+
32+
# Uncomment the following line to disable colors in ls.
33+
# DISABLE_LS_COLORS="true"
34+
35+
# Uncomment the following line to disable auto-setting terminal title.
36+
# DISABLE_AUTO_TITLE="true"
37+
38+
# Uncomment the following line to enable command auto-correction.
39+
# ENABLE_CORRECTION="true"
40+
41+
# Uncomment the following line to display red dots whilst waiting for completion.
42+
# COMPLETION_WAITING_DOTS="true"
43+
44+
# Uncomment the following line if you want to disable marking untracked files
45+
# under VCS as dirty. This makes repository status check for large repositories
46+
# much, much faster.
47+
# DISABLE_UNTRACKED_FILES_DIRTY="true"
48+
49+
# Uncomment the following line if you want to change the command execution time
50+
# stamp shown in the history command output.
51+
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
52+
# HIST_STAMPS="mm/dd/yyyy"
53+
54+
# Would you like to use another custom folder than $ZSH/custom?
55+
# ZSH_CUSTOM=/path/to/new-custom-folder
56+
57+
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
58+
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
59+
# Example format: plugins=(rails git textmate ruby lighthouse)
60+
# Add wisely, as too many plugins slow down shell startup.
61+
plugins=(git)
62+
63+
source $ZSH/oh-my-zsh.sh
64+
65+
# User configuration
66+
67+
# export MANPATH="/usr/local/man:$MANPATH"
68+
69+
# You may need to manually set your language environment
70+
# export LANG=en_US.UTF-8
71+
72+
# Preferred editor for local and remote sessions
73+
# if [[ -n $SSH_CONNECTION ]]; then
74+
# export EDITOR='vim'
75+
# else
76+
# export EDITOR='mvim'
77+
# fi
78+
79+
# Compilation flags
80+
# export ARCHFLAGS="-arch x86_64"
81+
82+
# ssh
83+
# export SSH_KEY_PATH="~/.ssh/dsa_id"
84+
85+
# Set personal aliases, overriding those provided by oh-my-zsh libs,
86+
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
87+
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
88+
# For a full list of active aliases, run `alias`.
89+
#
90+
# Example aliases
91+
# alias zshconfig="mate ~/.zshrc"
92+
# alias ohmyzsh="mate ~/.oh-my-zsh"
93+
#
94+
95+
alias art="php artisan"
96+
alias migrate="php artisan migrate"
97+
alias migrate:rollback="php artisan migrate:rollback"
98+
alias seed="php artisan db:seed"
99+
alias fire="php artisan event:fire"
100+
alias add="git add --all"
101+
alias add.="git add ."
102+
alias commit="git commit -m"
103+
alias push="git push"
104+
alias pull="git pull"
105+
alias fetch="git fetch"
106+
alias cparallel="./vendor/bin/paratest -p4 --runner=WrapperRunner --coverage-html=~/development/phpunit-coverage"
107+
alias cparalleltemp="./vendor/bin/paratest -p4 --runner=WrapperRunner --coverage-html=~/development/phpunit-coverage-temp"
108+
alias phpunit="./vendor/bin/phpunit --testdox --stop-on-error --stop-on-failure"
109+
alias phpunitsoe="phpunit --testdox --stop-on-error --stop-on-failure"
110+
111+
alias regen='composer dumpautoload; art ide-helper:generate'
112+
113+
alias pc="XDEBUG_MODE=coverage ./vendor/bin/phpunit --testdox --coverage-html ~/development/phpunit-coverage"
114+
alias pctemp="XDEBUG_MODE=coverage ./vendor/bin/phpunit --testdox --coverage-html ~/development/phpunit-coverage-temp"
115+
alias dumpseed="composer dumpautoload; art migrate:refresh --seed"
116+
117+
export PATH="/usr/local/sbin:$PATH"
118+
export PATH="$HOME/.composer/vendor/bin:$PATH"
119+
120+
alias regen='composer dumpautoload; art ide-helper:generate'
121+
export PATH="/usr/local/opt/libxml2/bin:$PATH"
122+
123+
source ~/.oh-my-zsh/custom/iTerm2-custom.zsh
124+
125+
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
126+
export PATH="$PATH:$HOME/.rvm/bin"
127+
128+
129+
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
#
2+
# Cobalt2 Custom Themes - https://github.com/rjacobsen2012/custom-themes
3+
#
4+
# # README
5+
#
6+
# In order for this theme to render correctly, you will need a
7+
# [Powerline-patched font](https://gist.github.com/1595572).
8+
##
9+
### Segment drawing
10+
# A few utility functions to make it easy and re-usable to draw segmented prompts
11+
12+
server_name=`hostname`
13+
eth1=`sudo ifconfig | grep "eth1"`
14+
eth0=`sudo ifconfig | grep "eth0"`
15+
EXTERNAL_IP=""
16+
17+
if [[ $eth1 != "" ]]; then
18+
EXTERNAL_IP=`sudo ifconfig eth1 | grep "inet addr" | cut -d ':' -f 2 | cut -d ' ' -f 1`
19+
elif [[ $eth0 != "" ]]; then
20+
EXTERNAL_IP=`sudo ifconfig eth0 | grep "inet addr" | cut -d ':' -f 2 | cut -d ' ' -f 1`
21+
fi
22+
23+
if [[ $eth1 = "" && $eth0 = "" ]]; then
24+
server_name="LOCAL"
25+
fi
26+
27+
CURRENT_BG='NONE'
28+
SEGMENT_SEPARATOR=''
29+
30+
# Begin a segment
31+
# Takes two arguments, background and foreground. Both can be omitted,
32+
# rendering default background/foreground.
33+
prompt_segment() {
34+
local bg fg
35+
[[ -n $1 ]] && bg="%K{$1}" || bg="%k"
36+
[[ -n $2 ]] && fg="%F{$2}" || fg="%f"
37+
if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then
38+
echo -n " %{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%} "
39+
else
40+
echo -n "%{$bg%} %F{blue}$server_name $EXTERNAL_IP%{$fg%}"
41+
# echo $(pwd | sed -e "s,^$HOME,~," | sed "s@\(.\)[^/]*/@\1/@g")
42+
# echo $(pwd | sed -e "s,^$HOME,~,")
43+
fi
44+
CURRENT_BG=$1
45+
[[ -n $3 ]] && echo -n $3
46+
}
47+
48+
prompt_segment_empty() {
49+
local bg fg
50+
[[ -n $1 ]] && bg="%K{$1}" || bg="%k"
51+
[[ -n $2 ]] && fg="%F{$2}" || fg="%f"
52+
if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then
53+
echo -n " %{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%} "
54+
else
55+
echo -n "%{$bg%}%{$fg%} "
56+
# echo $(pwd | sed -e "s,^$HOME,~," | sed "s@\(.\)[^/]*/@\1/@g")
57+
# echo $(pwd | sed -e "s,^$HOME,~,")
58+
fi
59+
CURRENT_BG=$1
60+
[[ -n $3 ]] && echo -n $3
61+
}
62+
63+
# End the prompt, closing any open segments
64+
prompt_end() {
65+
if [[ -n $CURRENT_BG ]]; then
66+
echo -n " %{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR"
67+
else
68+
echo -n "%{%k%}"
69+
fi
70+
echo -n "%{%f%}"
71+
CURRENT_BG=''
72+
}
73+
74+
### Prompt components
75+
# Each component will draw itself, and hide itself if no information needs to be shown
76+
77+
# Context: user@hostname (who am I and where am I)
78+
prompt_context() {
79+
local user=`whoami`
80+
81+
if [[ "$user" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
82+
prompt_segment black default "%(!.%{%F{yellow}%}.)"
83+
fi
84+
}
85+
86+
# Git: branch/detached head, dirty status
87+
prompt_git() {
88+
local ref dirty
89+
if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
90+
ZSH_THEME_GIT_PROMPT_DIRTY='±'
91+
dirty=$(parse_git_dirty)
92+
ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="$(git show-ref --head -s --abbrev |head -n1 2> /dev/null)"
93+
if [[ -n $dirty ]]; then
94+
prompt_segment yellow black
95+
else
96+
prompt_segment green black
97+
fi
98+
echo -n "${ref/refs\/heads\// }$dirty"
99+
fi
100+
}
101+
102+
# Dir: current working directory
103+
prompt_dir() {
104+
prompt_segment blue black '%3~'
105+
# prompt_segment blue black "…${PWD: -30}"
106+
}
107+
108+
# Status:
109+
# - was there an error
110+
# - am I root
111+
# - are there background jobs?
112+
prompt_status() {
113+
local symbols
114+
symbols=()
115+
[[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘"
116+
[[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡"
117+
[[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙"
118+
119+
[[ -n "$symbols" ]] && prompt_segment_empty black default "$symbols"
120+
}
121+
122+
## Main prompt
123+
build_prompt() {
124+
RETVAL=$?
125+
prompt_status
126+
prompt_context
127+
prompt_dir
128+
prompt_git
129+
prompt_end
130+
}
131+
132+
PROMPT='%{%f%b%k%}$(build_prompt) '
133+

‎resources/config/cobalt2.itermcolors

+213
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>Ansi 0 Color</key>
6+
<dict>
7+
<key>Blue Component</key>
8+
<real>0.0</real>
9+
<key>Green Component</key>
10+
<real>0.0</real>
11+
<key>Red Component</key>
12+
<real>0.0</real>
13+
</dict>
14+
<key>Ansi 1 Color</key>
15+
<dict>
16+
<key>Blue Component</key>
17+
<real>0.0</real>
18+
<key>Green Component</key>
19+
<real>0.0</real>
20+
<key>Red Component</key>
21+
<real>1</real>
22+
</dict>
23+
<key>Ansi 10 Color</key>
24+
<dict>
25+
<key>Blue Component</key>
26+
<real>0.11517760157585144</real>
27+
<key>Green Component</key>
28+
<real>0.81519794464111328</real>
29+
<key>Red Component</key>
30+
<real>0.23300750553607941</real>
31+
</dict>
32+
<key>Ansi 11 Color</key>
33+
<dict>
34+
<key>Blue Component</key>
35+
<real>0.035555899143218994</real>
36+
<key>Green Component</key>
37+
<real>0.78536456823348999</real>
38+
<key>Red Component</key>
39+
<real>0.92833864688873291</real>
40+
</dict>
41+
<key>Ansi 12 Color</key>
42+
<dict>
43+
<key>Blue Component</key>
44+
<real>1</real>
45+
<key>Green Component</key>
46+
<real>0.3333333432674408</real>
47+
<key>Red Component</key>
48+
<real>0.3333333432674408</real>
49+
</dict>
50+
<key>Ansi 13 Color</key>
51+
<dict>
52+
<key>Blue Component</key>
53+
<real>1</real>
54+
<key>Green Component</key>
55+
<real>0.3333333432674408</real>
56+
<key>Red Component</key>
57+
<real>1</real>
58+
</dict>
59+
<key>Ansi 14 Color</key>
60+
<dict>
61+
<key>Blue Component</key>
62+
<real>0.97867441177368164</real>
63+
<key>Green Component</key>
64+
<real>0.89121149225051699</real>
65+
<key>Red Component</key>
66+
<real>0.41672572861338453</real>
67+
</dict>
68+
<key>Ansi 15 Color</key>
69+
<dict>
70+
<key>Blue Component</key>
71+
<real>1</real>
72+
<key>Green Component</key>
73+
<real>1</real>
74+
<key>Red Component</key>
75+
<real>1</real>
76+
</dict>
77+
<key>Ansi 2 Color</key>
78+
<dict>
79+
<key>Blue Component</key>
80+
<real>0.13008742736566298</real>
81+
<key>Green Component</key>
82+
<real>0.87031603506787336</real>
83+
<key>Red Component</key>
84+
<real>0.21895777543895642</real>
85+
</dict>
86+
<key>Ansi 3 Color</key>
87+
<dict>
88+
<key>Blue Component</key>
89+
<real>0.039139740169048309</real>
90+
<key>Green Component</key>
91+
<real>0.89706093072891235</real>
92+
<key>Red Component</key>
93+
<real>0.99814993143081665</real>
94+
</dict>
95+
<key>Ansi 4 Color</key>
96+
<dict>
97+
<key>Blue Component</key>
98+
<real>0.82438474893569946</real>
99+
<key>Green Component</key>
100+
<real>0.37805050611495972</real>
101+
<key>Red Component</key>
102+
<real>0.079237513244152069</real>
103+
</dict>
104+
<key>Ansi 5 Color</key>
105+
<dict>
106+
<key>Blue Component</key>
107+
<real>0.36536297202110291</real>
108+
<key>Green Component</key>
109+
<real>0.0</real>
110+
<key>Red Component</key>
111+
<real>1</real>
112+
</dict>
113+
<key>Ansi 6 Color</key>
114+
<dict>
115+
<key>Blue Component</key>
116+
<real>0.73333334922790527</real>
117+
<key>Green Component</key>
118+
<real>0.73333334922790527</real>
119+
<key>Red Component</key>
120+
<real>0.0</real>
121+
</dict>
122+
<key>Ansi 7 Color</key>
123+
<dict>
124+
<key>Blue Component</key>
125+
<real>0.73333334922790527</real>
126+
<key>Green Component</key>
127+
<real>0.73333334922790527</real>
128+
<key>Red Component</key>
129+
<real>0.73333334922790527</real>
130+
</dict>
131+
<key>Ansi 8 Color</key>
132+
<dict>
133+
<key>Blue Component</key>
134+
<real>0.33333333333333331</real>
135+
<key>Green Component</key>
136+
<real>0.33333333333333331</real>
137+
<key>Red Component</key>
138+
<real>0.33333333333333331</real>
139+
</dict>
140+
<key>Ansi 9 Color</key>
141+
<dict>
142+
<key>Blue Component</key>
143+
<real>0.090362116694450378</real>
144+
<key>Green Component</key>
145+
<real>0.052976857870817184</real>
146+
<key>Red Component</key>
147+
<real>0.95708823204040527</real>
148+
</dict>
149+
<key>Background Color</key>
150+
<dict>
151+
<key>Blue Component</key>
152+
<real>0.21839480102062225</real>
153+
<key>Green Component</key>
154+
<real>0.15233974158763885</real>
155+
<key>Red Component</key>
156+
<real>0.073702715337276459</real>
157+
</dict>
158+
<key>Bold Color</key>
159+
<dict>
160+
<key>Blue Component</key>
161+
<real>1</real>
162+
<key>Green Component</key>
163+
<real>0.98771905899047852</real>
164+
<key>Red Component</key>
165+
<real>0.96919095516204834</real>
166+
</dict>
167+
<key>Cursor Color</key>
168+
<dict>
169+
<key>Blue Component</key>
170+
<real>0.03614787757396698</real>
171+
<key>Green Component</key>
172+
<real>0.79959547519683838</real>
173+
<key>Red Component</key>
174+
<real>0.94297069311141968</real>
175+
</dict>
176+
<key>Cursor Text Color</key>
177+
<dict>
178+
<key>Blue Component</key>
179+
<real>0.9480862021446228</real>
180+
<key>Green Component</key>
181+
<real>1</real>
182+
<key>Red Component</key>
183+
<real>0.99659550189971924</real>
184+
</dict>
185+
<key>Foreground Color</key>
186+
<dict>
187+
<key>Blue Component</key>
188+
<real>1</real>
189+
<key>Green Component</key>
190+
<real>1</real>
191+
<key>Red Component</key>
192+
<real>1</real>
193+
</dict>
194+
<key>Selected Text Color</key>
195+
<dict>
196+
<key>Blue Component</key>
197+
<real>0.70916998386383057</real>
198+
<key>Green Component</key>
199+
<real>0.70916998386383057</real>
200+
<key>Red Component</key>
201+
<real>0.70916998386383057</real>
202+
</dict>
203+
<key>Selection Color</key>
204+
<dict>
205+
<key>Blue Component</key>
206+
<real>0.31055498123168945</real>
207+
<key>Green Component</key>
208+
<real>0.20615114271640778</real>
209+
<key>Red Component</key>
210+
<real>0.09597768634557724</real>
211+
</dict>
212+
</dict>
213+
</plist>

‎resources/config/iTerm2-custom.zsh

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
if [[ -n "$ITERM_SESSION_ID" ]]; then
2+
function change-profile() {
3+
echo -ne "\033]50;SetProfile=$1\a"
4+
}
5+
6+
function reset-colors() {
7+
echo -ne "\033]6;1;bg;*;Default\a"
8+
change-profile Default
9+
}
10+
11+
function sshterm() {
12+
if [[ "$1" =~ "^ssh " ]]; then
13+
if [[ "$@*" =~ "production" ]]; then
14+
change-profile ssh_production
15+
elif [[ "$@*" =~ "development" ]]; then
16+
change-profile ssh_homeserver
17+
fi
18+
elif [[ "$1" =~ "^vagrant " ]]; then
19+
if [[ "$*" =~ "ssh" ]]; then
20+
change-profile ssh_vagrant
21+
fi
22+
else
23+
reset-colors
24+
fi
25+
}
26+
27+
autoload -U add-zsh-hook
28+
add-zsh-hook precmd reset-colors
29+
add-zsh-hook preexec sshterm
30+
fi

‎resources/config/iTerm2-profile.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"Profiles": [
3+
{
4+
"Name": "Hello Clair",
5+
"Guid": "A6AA340E-97DC-4949-9C6B-56D2245A50FC",
6+
"Dynamic Profile Parent Name": "Default",
7+
"Use Non-ASCII Font": false,
8+
"Normal Font": "Inconsolata for Powerline 14",
9+
"ASCII Anti Aliased": true,
10+
"Non Ascii Font": "Monaco 12",
11+
"Vertical Spacing": 1.26,
12+
"Use Bold Font": true,
13+
"Horizontal Spacing": 1
14+
}
15+
]
16+
}

‎resources/scripts/default-profile.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env python3.7
2+
3+
import iterm2
4+
5+
async def main(connection):
6+
all_profiles = await iterm2.PartialProfile.async_query(connection)
7+
for profile in all_profiles:
8+
if profile.name == "Hello Clair":
9+
await profile.async_make_default()
10+
return
11+
12+
iterm2.run_until_complete(main)

‎storage/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

0 commit comments

Comments
 (0)
Please sign in to comment.