commit 63b696c0bd63567c054496659a0a98d640b41fa7 Author: sup39 Date: Tue May 12 20:56:32 2020 +0900 Create zshrc, setup.sh(zshrc, vimrc) diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2846a41 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2020 sup39 + +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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..136c0a2 --- /dev/null +++ b/README.md @@ -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 diff --git a/setup.sh b/setup.sh new file mode 100644 index 0000000..c81a025 --- /dev/null +++ b/setup.sh @@ -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 < +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 --'