From b7a2066f415dcb47e510627770b89335a5636538 Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Fri, 23 Feb 2018 11:38:24 +0200 Subject: [PATCH] initial commit --- aliases.zsh | 3 +++ exports.zsh | 14 ++++++++++++++ functions.zsh | 17 +++++++++++++++++ oh-my-zsh.zsh | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ path.zsh | 25 +++++++++++++++++++++++++ zlogin | 1 + zshrc | 39 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 147 insertions(+) create mode 100644 aliases.zsh create mode 100644 exports.zsh create mode 100644 functions.zsh create mode 100644 oh-my-zsh.zsh create mode 100644 path.zsh create mode 100755 zlogin create mode 100755 zshrc diff --git a/aliases.zsh b/aliases.zsh new file mode 100644 index 0000000..10628ba --- /dev/null +++ b/aliases.zsh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +alias find="noglob find" diff --git a/exports.zsh b/exports.zsh new file mode 100644 index 0000000..5fcd4e1 --- /dev/null +++ b/exports.zsh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +export LANG="en_US.UTF-8" +export LC_ALL="$LANG" + +if [[ -n $SSH_CONNECTION ]]; then + export EDITOR="rmate" +else + export EDITOR="code" +fi + +export CLICOLOR=1 + +export SDKMAN_DIR="$HOME/.sdkman" diff --git a/functions.zsh b/functions.zsh new file mode 100644 index 0000000..ccb48c1 --- /dev/null +++ b/functions.zsh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +is_linux() { + [[ $OSTYPE == linux* ]] +} + +is_macos() { + [[ $OSTYPE == darwin* ]] +} + +command_exists() { + command -v "$1" >/dev/null 2>&1 +} + +source_if_exists() { + [[ -f $1 ]] && source "$1" +} diff --git a/oh-my-zsh.zsh b/oh-my-zsh.zsh new file mode 100644 index 0000000..7020f34 --- /dev/null +++ b/oh-my-zsh.zsh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +find_oh_my_zsh() { + for prefix in "$HOME/." "/usr/share/" "/usr/local/share/"; do + local zsh_dir="${prefix}oh-my-zsh" + if [[ -d "$zsh_dir" ]]; then + export ZSH="$zsh_dir" + break + fi + done +} + +configure_oh_my_zsh() { + # see https://github.com/robbyrussell/oh-my-zsh/wiki/Themes + export ZSH_THEME="agnoster" + + # use hyphen-insensitive completion (makes `_` and `-` interchangeable) + export HYPHEN_INSENSITIVE="true" + + # enable command auto-correction + export ENABLE_CORRECTION="true" + + # display red dots while waiting for completion + export COMPLETION_WAITING_DOTS="true" + + # disable marking untracked files under VCS as dirty (this makes repository + # status check for large repositories faster) + export DISABLE_UNTRACKED_FILES_DIRTY="true" + + # command execution time stamp shown in the history + export HIST_STAMPS="mm/dd/yyyy" + + # https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins + plugins=( + git + common-aliases + extract + zsh-syntax-highlighting + ) + + if is_linux; then + plugins+=(command-not-found) + fi +} + +find_oh_my_zsh +configure_oh_my_zsh +source "$ZSH/oh-my-zsh.sh" diff --git a/path.zsh b/path.zsh new file mode 100644 index 0000000..a1e6ba8 --- /dev/null +++ b/path.zsh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +prepend() { eval "export $1=\"$2:\$$1\""; } +append() { eval "export $1=\"\$$1:$2\""; } + +# user binaries +append PATH "$HOME/bin" +append PATH "$HOME/.local/bin" +# global Yarn packages +append PATH "$HOME/.config/yarn/global/node_modules/.bin" + +if is_macos; then + # GNU sed + prepend PATH "/usr/local/opt/gnu-tar/libexec/gnubin" + prepend MANPATH "/usr/local/opt/gnu-tar/libexec/gnuman" + # GNU tar + prepend PATH "/usr/local/opt/gnu-sed/libexec/gnubin" + prepend MANPATH "/usr/local/opt/gnu-sed/libexec/gnuman" + # GNU coreutils + prepend PATH "/usr/local/opt/coreutils/libexec/gnubin" + prepend MANPATH "/usr/local/opt/coreutils/libexec/gnuman" + # Haskell packages + append PATH "$HOME/Library/Haskell/bin" +fi + diff --git a/zlogin b/zlogin new file mode 100755 index 0000000..f1f641a --- /dev/null +++ b/zlogin @@ -0,0 +1 @@ +#!/usr/bin/env bash diff --git a/zshrc b/zshrc new file mode 100755 index 0000000..c5038e5 --- /dev/null +++ b/zshrc @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +find_dotfiles_dir() { + local readlink + # readlink=$(which greadlink || which readlink) + local script_path"=${(%):-%x}" + + if [[ -n "$script_path" && -x "$readlink" ]]; then + script_path=$($readlink -f "$script_path") + DOTFILES_DIR=$(dirname "$script_path") + else + for prefix in "$HOME/" "$HOME/." "/usr/share/" "/usr/local/share/"; do + local dotfiles_dir="${prefix}dotfiles" + if [[ -d "$dotfiles_dir" ]]; then + DOTFILES_DIR="$dotfiles_dir" + break + fi + done + fi + + if [[ -d $DOTFILES_DIR ]]; then + export DOTFILES_DIR + else + echo "dotfiles directory not found" + fi +} + +find_dotfiles_dir + +for script in "$DOTFILES_DIR"/{functions,path,exports,aliases,oh-my-zsh}.zsh; do + source "$script" +done + +# rbenv +command_exists rbenv && eval "$(rbenv init -)" +# sdkman +source_if_exists "$SDKMAN_DIR/bin/sdkman-init.sh" +# Yarn completion +source_if_exists "/usr/local/lib/node_modules/yarn-completions/node_modules/tabtab/.completions/yarn.zsh"