Create zshrc, setup.sh(zshrc, vimrc)

This commit is contained in:
sup39 2020-05-12 20:56:32 +09:00
commit 63b696c0bd
4 changed files with 108 additions and 0 deletions

21
LICENSE Normal file
View file

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2020 sup39 <sup39hakujun@gmail.com>
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.

27
README.md Normal file
View file

@ -0,0 +1,27 @@
# zsh-setup for sup39
## Usage
### Full setup
```zsh
curl https://raw.githubusercontent.com/sup39/zsh-setup/master/setup.sh | sh -
```
Alternatively, use the shortened url:
```zsh
curl http://pr8.work/0/sup39-zsh | sh -
```
### zshrc only
```zsh
curl https://raw.githubusercontent.com/sup39/zsh-setup/master/zshrc >> $HOME/.zshrc
```
## Content
### zshrc
- `~/.zshrc`
:warning: *OVERWRITE* if exists
### [vimrc](https://github.com/sup39/vimrc)
- `~/.vim/sup39`
- `~/.vimrc`
:bulb: No overwriting

10
setup.sh Normal file
View file

@ -0,0 +1,10 @@
#!/bin/sh
# .zshrc
curl https://raw.githubusercontent.com/sup39/zsh-setup/master/zshrc -o $HOME/.zshrc
# .vim/sup39
[ -d $HOME/.vim/sup39 ] || git clone https://github.com/sup39/vimrc $HOME/.vim/sup39
# .vimrc
[ -f $HOME/.vimrc ] || cat >$HOME/.vimrc <<EOF
source $HOME/.vim/sup39/plug.vim
source $HOME/.vim/sup39/vimrc
EOF

50
zshrc Normal file
View file

@ -0,0 +1,50 @@
## Basic
# enable comments in interactive-shell
setopt interactivecomments
# disable ^S ^Q
stty stop undef start undef
## Input
# use vim mode
bindkey -v
# imap jk to <ESC>
bindkey -Mviins -s jk '\e'
## Edit
# edit zshrc
vizr() {vi $HOME/.zshrc && source $HOME/.zshrc}
sczr() {source $HOME/.zshrc}
# edit zprofile
vizp() {vi $HOME/.zprofile && . $HOME/.zprofile}
# edit vimrc
viv() {vi $HOME/.vim/sup39/vimrc}
viV() {vi $HOME/.vimrc}
## Completion
# setup
autoload -U compinit; compinit -u
ZSHC_ROOT=$HOME/.zsh_complete
# edit
vizc() { [ -z $1 ] && local fn=$ZSHC_ROOT/$1 && vi $fn && [ -f $fn ] && . $fn }
compdef "_files -W $ZSHC_ROOT" vizc # completion for vizc
# source
sczc() {source <(find "$ZSHC_ROOT" -name "*.zsh" -exec cat {} \;)}
[ -d "$ZSHC_ROOT" ] && sczc # auto source once
## PS1
function zle-line-init zle-keymap-select {
local host='%m'
case $KEYMAP in
vicmd) # normal mode
PS1="%F{200}%n@$host%f:%1~%# ";;
main) # insert mode
PS1="%F{50}%n@$host%f:%1~%# ";;
esac
zle reset-prompt
}
zle -N zle-line-init
zle -N zle-keymap-select
## Alias
alias curl-json='curl -H"Content-Type:application/json"'
alias rand-sel='shuf -n1 -e --'