LoginSignup
6
8

More than 5 years have passed since last update.

Bash on Ubuntu on Windowsの設定

Last updated at Posted at 2016-08-04

Bash on Ubuntu on Windowsを試してみた。
どうやら日本語対応がまだらしく表示がよくずれる。正直まだまだbeta版って感じ。今後のアップデートに期待。
コマンドプロンプトから起動したBash on Ubuntu on Windowsはよく動作が変になるので、直接Bash on Ubuntu on Windowsの起動を勧める。
ちなみに設定は完全に個人用なのでもろもろ要注意。

Git

とりあえずgitを入れる。

$ sudo apt-get install git

gitの環境設定

$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com
$ git config --global color.ui true

確認

$ git config --list

~/.bashrc

とりあえずのエイリアスと ls の色が気持ち悪いので変更

~/.bashrc
#
#  Language
#
export LANG='ja_JP.utf8'
export LC_ALL='ja_JP.utf8'
export LC_MESSAGES='ja_JP.utf8
#
alias ls='ls --color'
alias ll='ls -l --color'                                                                  alias la='ls -la --color'
export LS_COLORS='di=01;32'

vim

clipboard使えないやつなので必要パッケージを入れる。
結局使えなかったのでいらない。

$ sudo apt-get -y install vim-gtk vim-athena vim-gnome
$ vim --version | grep clipboard # 確認
# +clipboard       +iconv           +path_extra      +toolbar
# +eval            +mouse_dec       +startuptime     +xterm_clipboard

まずmolokai(カラースキーマ)を入れる。

$ mkdir -p ~/.vim/colors
$ git clone https://github.com/tomasr/molokai
$ mv molokai/colors/molokai.vim ~/.vim/colors/
$ rm -r molokai

次に.vimrc
コマンドプロンプト並みの色しか使えないらしく、思ったカラースキーマになっていないのでちょいちょい書き換えた。

~/.vimrc
set encoding=utf-8
set fileencodings=utf-8,iso-2022-jp,euc-jp,sjis,ucs-bom
set fileformats=unix,dos,mac
syntax on
colorscheme molokai
set number
set hlsearch
set visualbell t_vb=
set expandtab
set tabstop=2
set shiftwidth=2
set softtabstop=2
set laststatus=2
set cursorline

set backspace=start,eol,indent
set whichwrap=b,s,[,],,~
highlight StatusLine term=none cterm=none ctermfg=black ctermbg=grey
highlight LineNr term=none cterm=NONE ctermfg=darkgrey
highlight PreProc term=none cterm=NONE ctermfg=darkcyan
highlight Import term=none cterm=none ctermfg=darkgreen
highlight NonText term=none cterm=none ctermfg=darkgrey ctermbg=none guibg=NONE guifg=Grey
highlight SpecialKey term=none cterm=none ctermfg=darkgrey ctermbg=none guibg=NONE guifg=Grey
highlight Comment term=italic cterm=none ctermfg=brown ctermbg=none guifg=#000000 guibg=#FFE792
"
set list
set listchars=tab:>.,trail:_,eol:,extends:>,precedes:<,nbsp:%
function! ZenkakuSpace()
    highlight ZenkakuSpace cterm=reverse ctermfg=DarkMagenta gui=reverse guifg=DarkMagenta
endfunction

if has('syntax')
    augroup ZenkakuSpace
        autocmd!
        autocmd ColorScheme       * call ZenkakuSpace()
        autocmd VimEnter,WinEnter * match ZenkakuSpace / /
    augroup END
    call ZenkakuSpace()
endif


augroup vimrcEx
  au BufRead * if line("'\"") > 0 && line("'\"") <= line("$") |
  \ exe "normal g`\"" | endif
augroup END

set clipboard+=unnamedplus

" Indent Python in the Google way.

let s:maxoff = 50 " maximum number of lines to look backwards.

function GetGooglePythonIndent(lnum)

  " Indent inside parens.
  " Align with the open paren unless it is at the end of the line.
  " E.g.
  "   open_paren_not_at_EOL(100,
  "                         (200,
  "                          300),
  "                         400)
  "   open_paren_at_EOL(
  "       100, 200, 300, 400)
  call cursor(a:lnum, 1)
  let [par_line, par_col] = searchpairpos('(¥|{¥|¥[', '', ')¥|}¥|¥]', 'bW',
        ¥ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :"
        ¥ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
        ¥ . " =‾ '¥¥(Comment¥¥|String¥¥)$'")
  if par_line > 0
    call cursor(par_line, 1)
    if par_col != col("$") - 1
      return par_col
    endif
  endif

  " Delegate the rest to the original function.
  return GetPythonIndent(a:lnum)

endfunction

let pyindent_nested_paren="&sw*2"
let pyindent_open_paren="&sw*2"


au BufRead, BufNewFile *.py setlocal indentexpr=GetGooglePythonIndent(v:lnum)

zsh + prezto

zshのインストール

$ sudo apt-get install zsh
$ zsh # zshを起動

preztoのインストールと導入

$ git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"
$ setopt EXTENDED_GLOB
for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do
  ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"
done
~/.zpreztorc
zstyle ':prezto:load' pmodule \
  'environment' \
  'terminal' \
  'editor' \
  'history' \
  'directory' \
  'spectrum' \
  'utility' \
  'completion' \
  'git' \ # 追加
  'prompt'

134行目あたり

~/.zprezto/modules/prompt/functions/prompt_sorin_setup
# PROMPT='${SSH_TTY:+"%F{9}%n%f%F{7}@%f%F{3}%m%f "}%F{4}${_prompt_sorin_pwd}%(!. %B%F{1}#%f%b.)${editor_info[keymap]} '
  PROMPT='${SSH_TTY:+"%F{9}%n%f%F{7}@%f%F{3}%m%f "}%F{8}${_prompt_sorin_pwd}%(!. %B%F{1}#%f%b.)${editor_info[keymap]} '
~/.zshrc
setopt no_beep

autoload colors
colors
export LSCOLORS=cxfxcxdxbxegedabagacad
export LS_COLORS='di=32;40:ln=35;40:so=32;40:pi=33;40:ex=31;40:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;46'
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}

Pyenv

$ sudo apt-get install gcc make openssl libssl-dev libbz2-dev libreadline-dev libsqlite3-dev
$ git clone git://github.com/yyuu/pyenv.git ~/.pyenv
~/.zshrc
# Pyenv↲
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
$ source ~/.zshrc
# あとは好きな設定をする。
$ pyenv install 2.7.11
$ pyenv rehash
$ pyenv global 2.7.11

virtualenv

$ sudo apt-get install python-pip python-dev python-virtualenv
6
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
8