-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split zshrc file, add installation script
Installation script works for zshrc only.
- Loading branch information
Vasily Laur
committed
Jul 11, 2016
1 parent
043cbb2
commit b5fe252
Showing
9 changed files
with
189 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
|
||
set -o errexit -o nounset -o pipefail | ||
SCRIPT_PATH="$(dirname $(readlink -f "$0"))" | ||
|
||
if [[ $1 = zshrc || $1 = zsh ]]; then | ||
echo '#This file was generated from dotfiles' > ~/.zshrc | ||
echo '#All changes made here will be overwritten on update' >> ~/.zshrc | ||
|
||
cat "$SCRIPT_PATH"/zsh/other.zsh >> ~/.zshrc | ||
|
||
echo '# history setup --------------------------------------------------------' >> ~/.zshrc | ||
cat "$SCRIPT_PATH"/zsh/history.zsh >> ~/.zshrc | ||
echo '# ----------------------------------------------------------------------' >> ~/.zshrc | ||
echo '' >> ~/.zshrc | ||
|
||
echo '# key bindings ---------------------------------------------------------' >> ~/.zshrc | ||
cat "$SCRIPT_PATH"/zsh/key_bindings.zsh >> ~/.zshrc | ||
echo '# ----------------------------------------------------------------------' >> ~/.zshrc | ||
echo '' >> ~/.zshrc | ||
|
||
echo '# prompt setup ---------------------------------------------------------' >> ~/.zshrc | ||
cat "$SCRIPT_PATH"/zsh/prompt.zsh >> ~/.zshrc | ||
echo '# ----------------------------------------------------------------------' >> ~/.zshrc | ||
echo '' >> ~/.zshrc | ||
|
||
echo '# window title setup ---------------------------------------------------' >> ~/.zshrc | ||
cat "$SCRIPT_PATH"/zsh/window_title.zsh >> ~/.zshrc | ||
echo '# ----------------------------------------------------------------------' >> ~/.zshrc | ||
echo '' >> ~/.zshrc | ||
|
||
echo '# aliases --------------------------------------------------------------' >> ~/.zshrc | ||
cat "$SCRIPT_PATH"/zsh/aliases.zsh >> ~/.zshrc | ||
echo '# ----------------------------------------------------------------------' >> ~/.zshrc | ||
echo '' >> ~/.zshrc | ||
|
||
echo '# functions setup ------------------------------------------------------' >> ~/.zshrc | ||
cat "$SCRIPT_PATH"/zsh/functions.zsh >> ~/.zshrc | ||
echo '# ----------------------------------------------------------------------' >> ~/.zshrc | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
alias ls='ls -F --color=auto' | ||
alias ll='ls -l --color=auto -h' | ||
alias la='ls -A --color=auto' | ||
alias lla='ll -A --color=auto -h' | ||
alias grep='grep --colour=auto' | ||
hash colordiff 2>/dev/null && alias diff='colordiff' | ||
|
||
# don't try to correct typos | ||
alias mkdir='nocorrect mkdir' | ||
alias mv='nocorrect mv' | ||
|
||
# aliases for file extensions | ||
alias -s txt=${EDITOR} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# cd and ls in one shot | ||
cdls() { | ||
local dir=$1 | ||
test -z "$dir" && dir="$HOME" | ||
cd "$dir" && ls | ||
} | ||
|
||
cdll() { | ||
local dir=$1 | ||
test -z "$dir" && dir="$HOME" | ||
cd "$dir" && ll | ||
} | ||
|
||
# classic archive extractor | ||
extract () { | ||
if [ -f $1 ] ; then | ||
case $1 in | ||
*.tar.bz2) tar xvjf $1 ;; | ||
*.tar.gz) tar xvzf $1 ;; | ||
*.bz2) bunzip2 $1 ;; | ||
*.rar) unrar x $1 ;; | ||
*.gz) gunzip $1 ;; | ||
*.tar) tar xvf $1 ;; | ||
*.tbz2) tar xvjf $1 ;; | ||
*.tgz) tar xvzf $1 ;; | ||
*.zip) unzip $1 ;; | ||
*.Z) uncompress $1 ;; | ||
*.7z) 7z x $1 ;; | ||
*) echo "'$1' cannot be extracted via $0" ;; | ||
esac | ||
else | ||
echo "'$1' is not a valid file" | ||
fi | ||
} | ||
|
||
# color man pages | ||
man() { | ||
env \ | ||
LESS_TERMCAP_mb=$(printf "\e[1;31m") \ | ||
LESS_TERMCAP_md=$(printf "\e[1;31m") \ | ||
LESS_TERMCAP_me=$(printf "\e[0m") \ | ||
LESS_TERMCAP_se=$(printf "\e[0m") \ | ||
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \ | ||
LESS_TERMCAP_ue=$(printf "\e[0m") \ | ||
LESS_TERMCAP_us=$(printf "\e[1;32m") \ | ||
man "$@" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
HISTFILE=~/.zhistory | ||
HISTSIZE=2000 | ||
SAVEHIST=2000 | ||
setopt APPEND_HISTORY | ||
setopt HIST_IGNORE_ALL_DUPS | ||
setopt HIST_REDUCE_BLANKS # remove blank lines from history file | ||
# if the command starts with a whitespace, don't add it to history | ||
setopt HIST_IGNORE_SPACE | ||
# append every single command to $HISTFILE immediately after hitting ENTER | ||
setopt INC_APPEND_HISTORY | ||
# shares the histories of multiple Z-Shells; commands from one active Zsh are | ||
# then placed in the other shell's history | ||
setopt SHARE_HISTORY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# don't guess preferred mode, always use emacs-style keybindings | ||
bindkey -e | ||
|
||
# to show hotkey symbol, press ctrl+V, than hotkey | ||
bindkey -M isearch '^R' history-incremental-search-backward | ||
bindkey -M isearch '^S' history-incremental-search-forward | ||
bindkey "^[[5~" history-beginning-search-backward # pg up | ||
bindkey "^[[6~" history-beginning-search-forward # pg down | ||
|
||
bindkey "^[[3~" delete-char # delete | ||
bindkey "^W" backward-delete-word # delete instead of kill | ||
bindkey "^A" beginning-of-line | ||
bindkey "^E" end-of-line | ||
|
||
case $TERM in | ||
rxvt|rxvt-unicode|rxvt-256color|rxvt-unicode-256color) | ||
bindkey '^[Od' emacs-backward-word # ctrl + left arrow | ||
bindkey '^[Oc' emacs-forward-word # ctrl + right arrow | ||
;; | ||
*) | ||
bindkey '^[[1;5D' emacs-backward-word # ctrl + left arrow | ||
bindkey '^[[1;5C' emacs-forward-word # ctrl + right arrow | ||
;; | ||
esac | ||
|
||
export WORDCHARS='_-' # symbols, that are a part of a word |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
typeset -U path | ||
path=(~/bin $path) | ||
|
||
setopt autocd # change directory without typing cd | ||
setopt correctall # correct typos | ||
setopt NO_BEEP | ||
|
||
# enable completion | ||
autoload -U compinit && compinit | ||
|
||
# use arrow keys to navigate completion suggestions | ||
setopt menucomplete | ||
zstyle ':completion:*' menu select=1 _complete _ignored _approximate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" ]]; then | ||
if [[ $EUID == 0 ]]; then | ||
PROMPT=$'%{\e[1;31m%}%~ %{\e[0m%}' # root | ||
else | ||
PROMPT=$'%{\e[1;33m%}%~ %{\e[0m%}' # regular user | ||
fi | ||
# right prompt with hostname or bad smiley | ||
RPROMPT=$'%(?,%{\e[34m%}ssh %n@%m%{\e[0m%},%{\e[1;31m%}:(%{\e[0m%})' | ||
else # not SSH | ||
if [[ $EUID == 0 ]]; then | ||
PROMPT=$'%{\e[1;31m%}%~ %{\e[0m%}' # root | ||
else | ||
PROMPT=$'%{\e[1;32m%}%~ %{\e[0m%}' # regular user | ||
fi | ||
# right prompt with hostname or bad smiley | ||
RPROMPT=$'%(?,%{\e[34m%}%m%{\e[0m%},%{\e[1;31m%}:(%{\e[0m%})' | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
case $TERM in | ||
termite|*xterm*|rxvt|rxvt-unicode|rxvt-256color|rxvt-unicode-256color|(dt|k|E)term) | ||
precmd () | ||
{ | ||
if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" || $EUID == 0 ]]; then | ||
print -Pn "\e]0;%n@%m:%~\a" | ||
else | ||
print -Pn "\e]0;%~\a" # regular user | ||
fi | ||
} | ||
preexec () | ||
{ | ||
if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" || $EUID == 0 ]]; then | ||
print -Pn "\e]0;%n@%m $1\a" | ||
else | ||
print -Pn "\e]0;$1\a" # regular user | ||
fi | ||
} | ||
;; | ||
esac |