From 92cf0b3fcf394213d04575b4597994bbf15b43ab Mon Sep 17 00:00:00 2001 From: Plaza521 Date: Fri, 27 Oct 2023 16:50:35 +0300 Subject: [PATCH] Add installing script for zsh config --- install_zsh.sh | 20 ++ zsh/.zshrc | 8 +- zsh/headline.zsh-theme | 514 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 536 insertions(+), 6 deletions(-) create mode 100644 install_zsh.sh create mode 100644 zsh/headline.zsh-theme diff --git a/install_zsh.sh b/install_zsh.sh new file mode 100644 index 0000000..a9f9a2c --- /dev/null +++ b/install_zsh.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# Check if git installed +if ! command -v git &> /dev/null; then + echo "This script requires git" + exit 1 +fi + +# Asking if user really want to install +read -p 'This script will install oh my zsh and replace .zshrc with its own. If you still want to run it, type "y": ' -n 1 -r +echo +if [[ ! $REPLY =~ ^[Yy]$ ]]; then + exit 1 +fi + +# Installing +set -x +wget -O ~/.zshrc https://nakidai.ddns.net/nakidai/dotfiles/raw/branch/master/zsh/.zshrc +git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting +wget -O ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/headline.zsh-theme https://nakidai.ddns.net/nakidai/dotfiles/raw/branch/master/zsh/headline.zsh-theme diff --git a/zsh/.zshrc b/zsh/.zshrc index bde93df..2bcbe85 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -1,12 +1,8 @@ export ZSH="$HOME/.oh-my-zsh" export EDITOR=nvim -XDG_CONFIG_HOME="~/.config" -plugins=(git) -source ~/headline.zsh-theme - +ZSH_THEME="headline" +plugins=(git zsh-syntax-highlighting) source $ZSH/oh-my-zsh.sh -source ~/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh - # Functions function reset-cursor() { diff --git a/zsh/headline.zsh-theme b/zsh/headline.zsh-theme new file mode 100644 index 0000000..91f440c --- /dev/null +++ b/zsh/headline.zsh-theme @@ -0,0 +1,514 @@ +#!/bin/zsh + +# Headline ZSH Prompt +# Copyright (c) 2022 Moarram under the MIT License + +# To install, source this file from your .zshrc file +# Customization variables begin around line 70 + + + +# Formatting aliases +# (add more if you need) +reset=$'\e[0m' +bold=$'\e[1m' +faint=$'\e[2m' +italic=$'\e[3m' +underline=$'\e[4m' +invert=$'\e[7m' +# ... + +# Foreground color aliases +black=$'\e[30m' +red=$'\e[31m' +green=$'\e[32m' +yellow=$'\e[33m' +blue=$'\e[34m' +magenta=$'\e[35m' +cyan=$'\e[36m' +white=$'\e[37m' +light_black=$'\e[90m' +light_red=$'\e[91m' +light_green=$'\e[92m' +light_yellow=$'\e[93m' +light_blue=$'\e[94m' +light_magenta=$'\e[95m' +light_cyan=$'\e[96m' +light_white=$'\e[97m' + +# Background color aliases +black_back=$'\e[40m' +red_back=$'\e[41m' +green_back=$'\e[42m' +yellow_back=$'\e[43m' +blue_back=$'\e[44m' +magenta_back=$'\e[45m' +cyan_back=$'\e[46m' +white_back=$'\e[47m' +light_black_back=$'\e[100m' +light_red_back=$'\e[101m' +light_green_back=$'\e[102m' +light_yellow_back=$'\e[103m' +light_blue_back=$'\e[104m' +light_magenta_back=$'\e[105m' +light_cyan_back=$'\e[106m' +light_white_back=$'\e[107m' + +# Custom colors +# REF: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters +# orange_yellow=$'\e[38;5;214m' # example 8-bit color +# orange_brown=$'\e[38;2;191;116;46m' # example rgb color +# ... + +# Flags +! [ -z "$SSH_TTY$SSH_CONNECTION$SSH_CLIENT" ] +IS_SSH=$? # 0=true, 1=false + + + +# ------------------------------------------------------------------------------ +# Customization +# Use the following variables to customize the theme +# These variables can also be set in your ~/.zshrc after sourcing this file +# The style aliases for ANSI SGR codes (defined above) can be used there too + +# Info sources (enclose in single quotes as these will be eval'd, use empty string to hide segment) +HEADLINE_USER_CMD='echo $USER' +HEADLINE_HOST_CMD='hostname -s' # consider 'basename "$VIRTUAL_ENV"' to replace host with environment +HEADLINE_PATH_CMD='print -rP "%~"' +HEADLINE_GIT_BRANCH_CMD='headline_git_branch' +HEADLINE_GIT_STATUS_CMD='headline_git_status' + +# Info symbols (optional) +HEADLINE_USER_PREFIX='' # consider " " +HEADLINE_HOST_PREFIX='' # consider " " +HEADLINE_PATH_PREFIX='' # consider " " +HEADLINE_BRANCH_PREFIX='' # consider " " + +# Info joints +HEADLINE_USER_BEGIN='' +if [ $IS_SSH = 0 ]; then HEADLINE_USER_BEGIN='=> '; fi +HEADLINE_USER_TO_HOST=' @ ' +HEADLINE_HOST_TO_PATH=': ' +HEADLINE_PATH_TO_BRANCH=' | ' # only used when no padding between and +HEADLINE_PATH_TO_PAD='' # used if padding between and +HEADLINE_PAD_TO_BRANCH='' # used if padding between and +HEADLINE_BRANCH_TO_STATUS=' [' +HEADLINE_STATUS_TO_STATUS='' # between each status section, consider "]" +HEADLINE_STATUS_END=']' + +# Info padding character +HEADLINE_PAD_CHAR=' ' # repeated for space between and + +# Info truncation symbol +HEADLINE_TRUNC_PREFIX='...' # shown where or is truncated, consider "…" + +# Info styles +HEADLINE_STYLE_DEFAULT='' # style applied to entire info line +HEADLINE_STYLE_JOINT=$light_black +HEADLINE_STYLE_USER=$bold$red +HEADLINE_STYLE_HOST=$bold$yellow +HEADLINE_STYLE_PATH=$bold$blue +HEADLINE_STYLE_BRANCH=$bold$cyan +HEADLINE_STYLE_STATUS=$bold$magenta + +# Info options +HEADLINE_INFO_MODE=precmd # precmd|prompt (whether info line is in PROMPT or printed by precmd) + # use "precmd" for window resize to work properly (but Ctrl+L doesn't show info line) + # use "prompt" for Ctrl+L to clear properly (but window resize eats previous output) + +# Separator options +HEADLINE_LINE_MODE=on # on|auto|off (whether to print the line above the prompt) + +# Separator character +HEADLINE_LINE_CHAR='_' # repeated for line above information + +# Separator styles +HEADLINE_STYLE_JOINT_LINE=$HEADLINE_STYLE_JOINT +HEADLINE_STYLE_USER_LINE=$HEADLINE_STYLE_USER +HEADLINE_STYLE_HOST_LINE=$HEADLINE_STYLE_HOST +HEADLINE_STYLE_PATH_LINE=$HEADLINE_STYLE_PATH +HEADLINE_STYLE_BRANCH_LINE=$HEADLINE_STYLE_BRANCH +HEADLINE_STYLE_STATUS_LINE=$HEADLINE_STYLE_STATUS + +# Git branch characters +HEADLINE_GIT_HASH=':' # hash prefix to distinguish from branch + +# Git status characters +# To set individual status styles use "%{$reset