LoginSignup
15
27

More than 5 years have passed since last update.

MSYS2設定ファイルを弄る

Last updated at Posted at 2016-09-23

MSYS2設定ファイル

HOMEディレクトリにある以下のファイルでいろいろ設定されています。

  • .bash_profile : 起動時に一度だけ読み込まれる
  • .bashrc : 起動時に一度だけ読み込まれる
  • .bash_aliases : alias書くところ
  • .bash_function : function書くところ
  • etc/fstab,etc/profile : 環境変数書くところ
  • .inputrc : キー操作を書くところ

msys2においてaliasの追加、環境変数の追加について書いた記事です。

準備

MSYS2のインストールはこちらから。
MSYS2 installer One click installer for msys2
環境変数をいじっていない人は
C:/User/Program Files/msys64/home以下にあるのではないでしょうか。
linuxっぽく環境変数に'HOME'という名前で、自分のよく使うフォルダを設定しておくとこれからCUIツール使っていく上で何かと都合がよいです。。
僕の場合はHOME=E:/U1and0/Dropbox/Program

.bash_profile

起動時に一度だけ読み込まれる
.bashrcを読み込むように指示

.bash_profile
echo '--Loading ~/.bash_profile--'
# To the extent possible under law, the author(s) have dedicated all 
# copyright and related and neighboring rights to this software to the 
# public domain worldwide. This software is distributed without any warranty. 
# You should have received a copy of the CC0 Public Domain Dedication along 
# with this software. 
# If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. 

# ~/.bash_profile: executed by bash(1) for login shells.

# The copy in your home directory (~/.bash_profile) is yours, please
# feel free to customise it to create a shell
# environment to your liking.  If you feel a change
# would be benifitial to all, please feel free to send
# a patch to the msys2 mailing list.

# User dependent .bash_profile file

# source the users bashrc if it exists
if [ -f "${HOME}/.bashrc" ] ; then
  source "${HOME}/.bashrc"
fi

# Set PATH so it includes user's private bin if it exists
# if [ -d "${HOME}/bin" ] ; then
#   PATH="${HOME}/bin:${PATH}"
# fi

# Set MANPATH so it includes users' private man if it exists
# if [ -d "${HOME}/man" ]; then
#   MANPATH="${HOME}/man:${MANPATH}"
# fi

# Set INFOPATH so it includes users' private info if it exists
# if [ -d "${HOME}/info" ]; then
#   INFOPATH="${HOME}/info:${INFOPATH}"
# fi

.bashrc

起動時に一度だけ読み込まれる

  • .bash_aliases
  • .bash_function の読み込みを指示
.bashrc
echo '--Loading ~/.bashrc--'
# To the extent possible under law, the author(s) have dedicated all 
# copyright and related and neighboring rights to this software to the 
# public domain worldwide. This software is distributed without any warranty. 
# You should have received a copy of the CC0 Public Domain Dedication along 
# with this software. 
# If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. 

# ~/.bashrc: executed by bash(1) for interactive shells.

# The copy in your home directory (~/.bashrc) is yours, please
# feel free to customise it to create a shell
# environment to your liking.  If you feel a change
# would be benifitial to all, please feel free to send
# a patch to the msys2 mailing list.

# User dependent .bashrc file

# If not running interactively, don't do anything
[[ "$-" != *i* ]] && return

# Shell Options
#
# See man bash for more options...
#
# Don't wait for job termination notification
# set -o notify
#
# Don't use ^D to exit
# set -o ignoreeof
#
# Use case-insensitive filename globbing
# shopt -s nocaseglob
#
# Make bash append rather than overwrite the history on disk
# shopt -s histappend
#
# When changing directory small typos can be ignored by bash
# for example, cd /vr/lgo/apaache would find /var/log/apache
# shopt -s cdspell

# Completion options
#
# These completion tuning parameters change the default behavior of bash_completion:
#
# Define to access remotely checked-out files over passwordless ssh for CVS
# COMP_CVS_REMOTE=1
#
# Define to avoid stripping description in --option=description of './configure --help'
# COMP_CONFIGURE_HINTS=1
#
# Define to avoid flattening internal contents of tar files
# COMP_TAR_INTERNAL_PATHS=1
#
# Uncomment to turn on programmable completion enhancements.
# Any completions you add in ~/.bash_completion are sourced last.
# [[ -f /etc/bash_completion ]] && . /etc/bash_completion

# History Options
#
# Don't put duplicate lines in the history.
# export HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoredups
#
# Ignore some controlling instructions
# HISTIGNORE is a colon-delimited list of patterns which should be excluded.
# The '&' is a special pattern which suppresses duplicate entries.
# export HISTIGNORE=$'[ \t]*:&:[fb]g:exit'
# export HISTIGNORE=$'[ \t]*:&:[fb]g:exit:ls' # Ignore the ls command as well
#
# Whenever displaying the prompt, write the previous line to disk
# export PROMPT_COMMAND="history -a"

# Aliases
#
# Some people use a different file for aliases
# .bash_aliasesを読み込むようにする
if [ -f "${HOME}/.bash_aliases" ]; then
  source "${HOME}/.bash_aliases"
fi
#
# Some example alias instructions
# If these are enabled they will be used instead of any instructions
# they may mask.  For example, alias rm='rm -i' will mask the rm
# application.  To override the alias instruction use a \ before, ie
# \rm will call the real rm not the alias.
#
# Interactive operation...
# alias rm='rm -i'
# alias cp='cp -i'
# alias mv='mv -i'
#
# Default to human readable figures
# alias df='df -h'
# alias du='du -h'
#
# Misc :)
# alias less='less -r'                          # raw control characters
# alias whence='type -a'                        # where, of a sort
# alias grep='grep --color'                     # show differences in colour
# alias egrep='egrep --color=auto'              # show differences in colour
# alias fgrep='fgrep --color=auto'              # show differences in colour
#
# Some shortcuts for different directory listings
# alias ls='ls -hF --color=tty'                 # classify files in colour
# alias dir='ls --color=auto --format=vertical'
# alias vdir='ls --color=auto --format=long'
# alias ll='ls -l'                              # long list
# alias la='ls -A'                              # all but . and ..
# alias l='ls -CF'                              #

# Umask
#
# /etc/profile sets 022, removing write perms to group + others.
# Set a more restrictive umask: i.e. no exec perms for others:
# umask 027
# Paranoid: neither group nor others have any perms:
# umask 077

# Functions
#
# Some people use a different file for functions
if [ -f "${HOME}/.bash_functions" ]; then
  source "${HOME}/.bash_functions"
fi
#
# Some example functions:
#
# a) function settitle
# settitle () 
# { 
#   echo -ne "\e]2;$@\a\e]1;$@\a"; 
# }
# 
# b) function cd_func
# This function defines a 'cd' replacement function capable of keeping, 
# displaying and accessing history of visited directories, up to 10 entries.
# To use it, uncomment it, source this file and try 'cd --'.
# acd_func 1.0.5, 10-nov-2004
# Petar Marinov, http:/geocities.com/h2428, this is public domain
# cd_func ()
# {
#   local x2 the_new_dir adir index
#   local -i cnt
# 
#   if [[ $1 ==  "--" ]]; then
#     dirs -v
#     return 0
#   fi
# 
#   the_new_dir=$1
#   [[ -z $1 ]] && the_new_dir=$HOME
# 
#   if [[ ${the_new_dir:0:1} == '-' ]]; then
#     #
#     # Extract dir N from dirs
#     index=${the_new_dir:1}
#     [[ -z $index ]] && index=1
#     adir=$(dirs +$index)
#     [[ -z $adir ]] && return 1
#     the_new_dir=$adir
#   fi
# 
#   #
#   # '~' has to be substituted by ${HOME}
#   [[ ${the_new_dir:0:1} == '~' ]] && the_new_dir="${HOME}${the_new_dir:1}"
# 
#   #
#   # Now change to the new dir and add to the top of the stack
#   pushd "${the_new_dir}" > /dev/null
#   [[ $? -ne 0 ]] && return 1
#   the_new_dir=$(pwd)
# 
#   #
#   # Trim down everything beyond 11th entry
#   popd -n +11 2>/dev/null 1>/dev/null
# 
#   #
#   # Remove any other occurence of this dir, skipping the top of the stack
#   for ((cnt=1; cnt <= 10; cnt++)); do
#     x2=$(dirs +${cnt} 2>/dev/null)
#     [[ $? -ne 0 ]] && return 0
#     [[ ${x2:0:1} == '~' ]] && x2="${HOME}${x2:1}"
#     if [[ "${x2}" == "${the_new_dir}" ]]; then
#       popd -n +$cnt 2>/dev/null 1>/dev/null
#       cnt=cnt-1
#     fi
#   done
# 
#   return 0
# }
# 
# alias cd=cd_func







# gitの本にかいってあったけどよくわかんない
# export GIT_PS1_SHOWDIRTYSTATE=1
# export PS1='\W$(__git_ps1 " (%s)")\$'
# if [ -f "${HOME}/.git-prompt.sh" ]; then
#   source "${HOME}/.git-prompt.sh"
# fi

.bash_profileと.bashrcの使い分け

.bash_profileと.bashrcの使い分けですが、ログイン時に一度設定すればいいものは前者に、bashを起動するたびに設定する必要のあるものは後者にするのが原則です

bashの便利な機能を使いこなそう (2/2)

.bash_aliases

aliasを書き込んでおくところ

.bash_aliases
echo '--Loading ~/.bash_aliases--'

# Aliases for MSYS2 bash
# alias hogeを一時的に無効にするには\hoge

# 移動しやすく
alias ..='cd ..'
alias ...='cd ../..'
alias -- -='cd -'

# lsを使いやすく
alias ls='ls --color=auto --show-control-chars --time-style=long-iso -FH'
alias ll='ls -lA'
alias la='ls -A'

# 設定の読み込み
alias relogin='exec $SHELL -l'
alias re=relogin

# 画面消去
alias c=clear
alias cls=reset

# Windowsっぽく
alias dir=ll
alias path='echo -e ${PATH//:/\\n}'

# ディスクサイズ
alias df='df -h'
alias du='du -h'
alias du1='du -d1'


# find custom
alias findx='find . -name'

# grep custom
    # grep -r hogeで./以下のファイルの中身からhogeを検索
    # find | grep hogeで./以下のファイル名からhogeを検索
    # whereis hogeでコマンドの関連場所を検索(bin, src, man)
    # type -a hogeでコマンドを検索
alias grep='grep --color'
alias grepx='grep --color=always -nriC'
# "grepx 1 検索文字列"で前後一行の表示、"grepx 2 検索文字列"で前後2行の表示

# Windowsコマンド文字化け対策
function wincmd()
{
    CMD=$1
    shift
    $CMD 2>&1 | iconv -f CP932 -t UTF-8
}
alias cmd='winpty cmd'
alias psh='winpty powershell'
alias ipconfig='wincmd ipconfig'
alias netstat='wincmd netstat'
alias netsh='wincmd netsh'
# pingのコマンド名混同を避けるため絶対パスで指定
alias ping='wincmd /c/windows/system32/ping'

# ネットワーク確認用
alias ping1='ping www.google.com'
alias ping2='ping 192.168.0.1'

# mingw32用
# msysのmakeと被らないようにコマンド名が変えられている
alias make='mingw32-make'
alias m='make -j3'

#sublime text
alias subl='sublime_text.exe'

# python
alias py='python'
alias ipy='ipython'
alias jpy='jupyter qtconsole --style=monokai'
# git
alias g='git'
alias gf='git flow'

# add,commit,push
alias ga='git add'
alias gaa='git add .'
alias gan='git add -n .'
alias gaundo='git reset HEAD'
alias gac='git commit -am'
alias gc='git commit -m'
alias gcundo='git commit --amend'
alias gp='git push'
alias gpo='git push origin'

# status
alias gs='git status --short'
alias gsb='git status --short --branch'
alias gl='git log --oneline --all --graph --decorate'
alias gls='git ls-files'
alias gd='git diff --color-words'

# branch
alias gch='git checkout'
alias gb='git branch'
alias gm='git merge'
alias gt='git tag'

.bash_function

便利functionを書き込んでおくところ

.bash_functions
echo '--Loading ~/.bash_functions--'

# Functions for MSYS2 bash

# pacman for mingw32
function pinst()
{
    pacman -S "mingw-w64-i686-$1"
}
function puninst()
{
    pacman -Rs "mingw-w64-i686-$1"
}

# others
function snow()
{
    clear;while :;do echo $LINES $COLUMNS $(($RANDOM%$COLUMNS));sleep 0.1;done|gawk '{a[$3]=0;for(x in a) {o=a[x];a[x]=a[x]+1;printf "\033[%s;%sH ",o,x;printf "\033[%s;%sH*\033[0;0H",a[x],x;}}'
}

function matrix()
{
    echo -e "\e[1;40m" ; clear ; while :; do echo $LINES $COLUMNS $(( $RANDOM % $COLUMNS)) $(( $RANDOM % 72 )) ;sleep 0.05; done|gawk '{ letters="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%^&*()"; c=$4; letter=substr(letters,c,1);a[$3]=0;for (x in a) {o=a[x];a[x]=a[x]+1; printf "\033[%s;%sH\033[2;32m%s",o,x,letter; printf "\033[%s;%sH\033[1;37m%s\033[0;0H",a[x],x,letter;if (a[x] >= $1) { a[x]=0; } }}'
}

etc/fstab, etc/profile

msys64/etc以下にあるファイル。

fstab
# For a description of the file format, see the Users Guide
# http://cygwin.com/cygwin-ug-net/using.html#mount-table

# DO NOT REMOVE NEXT LINE. It remove cygdrive prefix from path
none / cygdrive binary,posix=0,noacl,user 0 0

C:/tools/Anaconda3/Scripts /conda
C:/tools/Anaconda3 /Anaconda3
C:/Program\040Files/gnuplot/bin/ /gnuplot
C:/Program\040Files/Sublime\040Text\0403 /subl

profile
# To the extent possible under law, the author(s) have dedicated all 
# copyright and related and neighboring rights to this software to the 
# public domain worldwide. This software is distributed without any warranty. 
# You should have received a copy of the CC0 Public Domain Dedication along 
# with this software. 
# If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. 


# System-wide profile file

# Some resources...
# Customizing Your Shell: http://www.dsl.org/cookbook/cookbook_5.html#SEC69
# Consistent BackSpace and Delete Configuration:
#   http://www.ibb.net/~anne/keyboard.html
# The Linux Documentation Project: http://www.tldp.org/
# The Linux Cookbook: http://www.tldp.org/LDP/linuxcookbook/html/
# Greg's Wiki http://mywiki.wooledge.org/

# Setup some default paths. Note that this order will allow user installed
# software to override 'system' software.
# Modifying these default path settings can be done in different ways.
# To learn more about startup files, refer to your shell's man page.

MSYS2_PATH="/usr/local/bin:/usr/bin:/bin"
MANPATH='/usr/local/man:/usr/share/man:/usr/man:/share/man'
INFOPATH='/usr/local/info:/usr/share/info:/usr/info:/share/info'

case "${MSYS2_PATH_TYPE:-minimal}" in
  strict)
    # Do not inherit any path configuration, and allow for full customization
    # of external path. This is supposed to be used in special cases such as
    # debugging without need to change this file, but not daily usage.
    unset ORIGINAL_PATH
    ;;
  inherit)
    # Inherit previous path. Note that this will make all of the Windows path
    # available in current shell, with possible interference in project builds.
    ORIGINAL_PATH="${ORIGINAL_PATH:-${PATH}}"
    ;;
  *)
    # Do not inherit any path configuration but configure a default Windows path
    # suitable for normal usage with minimal external interference.
    WIN_ROOT="$(PATH=${MSYS2_PATH} cygpath -Wu)"
    ORIGINAL_PATH="${WIN_ROOT}/System32:${WIN_ROOT}:${WIN_ROOT}/System32/Wbem:${WIN_ROOT}/System32/WindowsPowerShell/v1.0/:/Anaconda3:/conda:/subl:/gnuplot"
esac

unset MINGW_MOUNT_POINT
source '/etc/msystem'
case "${MSYSTEM}" in
MINGW32)
  MINGW_MOUNT_POINT="${MINGW_PREFIX}"
  PATH="${MINGW_MOUNT_POINT}/bin:${MSYS2_PATH}${ORIGINAL_PATH:+:${ORIGINAL_PATH}}"
  PKG_CONFIG_PATH="${MINGW_MOUNT_POINT}/lib/pkgconfig:${MINGW_MOUNT_POINT}/share/pkgconfig"
  ACLOCAL_PATH="${MINGW_MOUNT_POINT}/share/aclocal:/usr/share/aclocal"
  MANPATH="${MINGW_MOUNT_POINT}/share/man:${MANPATH}"
  ;;
MINGW64)
  MINGW_MOUNT_POINT="${MINGW_PREFIX}"
  PATH="${MINGW_MOUNT_POINT}/bin:${MSYS2_PATH}${ORIGINAL_PATH:+:${ORIGINAL_PATH}}"
  PKG_CONFIG_PATH="${MINGW_MOUNT_POINT}/lib/pkgconfig:${MINGW_MOUNT_POINT}/share/pkgconfig"
  ACLOCAL_PATH="${MINGW_MOUNT_POINT}/share/aclocal:/usr/share/aclocal"
  MANPATH="${MINGW_MOUNT_POINT}/share/man:${MANPATH}"
  ;;
*)
  PATH="${MSYS2_PATH}:/opt/bin${ORIGINAL_PATH:+:${ORIGINAL_PATH}}"
  PKG_CONFIG_PATH="/usr/lib/pkgconfig:/usr/share/pkgconfig:/lib/pkgconfig"
esac

MAYBE_FIRST_START=false
SYSCONFDIR="${SYSCONFDIR:=/etc}"

# TMP and TEMP as defined in the Windows environment must be kept
# for windows apps, even if started from msys2. However, leaving
# them set to the default Windows temporary directory or unset
# can have unexpected consequences for msys2 apps, so we define 
# our own to match GNU/Linux behaviour.
#
# Note: this uppercase/lowercase workaround does not seem to work.
# In fact, it has been removed from Cygwin some years ago. See:
#
#     * https://cygwin.com/git/gitweb.cgi?p=cygwin-apps/base-files.git;a=commitdiff;h=3e54b07
#     * https://cygwin.com/git/gitweb.cgi?p=cygwin-apps/base-files.git;a=commitdiff;h=7f09aef
#
ORIGINAL_TMP="${ORIGINAL_TMP:-${TMP}}"
ORIGINAL_TEMP="${ORIGINAL_TEMP:-${TEMP}}"
unset TMP TEMP
tmp=$(cygpath -w "$ORIGINAL_TMP" 2> /dev/null)
temp=$(cygpath -w "$ORIGINAL_TEMP" 2> /dev/null)
TMP="/tmp"
TEMP="/tmp"

# Define default printer
p='/proc/registry/HKEY_CURRENT_USER/Software/Microsoft/Windows NT/CurrentVersion/Windows/Device'
if [ -e "${p}" ] ; then
  read -r PRINTER < "${p}" 
  PRINTER=${PRINTER%%,*}
fi
unset p

print_flags ()
{
  (( $1 & 0x0002 )) && echo -n "binary" || echo -n "text"
  (( $1 & 0x0010 )) && echo -n ",exec"
  (( $1 & 0x0040 )) && echo -n ",cygexec"
  (( $1 & 0x0100 )) && echo -n ",notexec"
}

# Shell dependent settings
profile_d ()
{
  local file=
  for file in $(export LC_COLLATE=C; echo /etc/profile.d/*.$1); do
    [ -e "${file}" ] && . "${file}"
  done

  if [ -n "${MINGW_MOUNT_POINT}" ]; then
    for file in $(export LC_COLLATE=C; echo ${MINGW_MOUNT_POINT}/etc/profile.d/*.$1); do
      [ -e "${file}" ] && . "${file}"
    done
  fi
}

for postinst in $(export LC_COLLATE=C; echo /etc/post-install/*.post); do
  [ -e "${postinst}" ] && . "${postinst}"
done

if [ ! "x${BASH_VERSION}" = "x" ]; then
  HOSTNAME="$(/usr/bin/hostname)"
  profile_d sh
  [ -f "/etc/bash.bashrc" ] && . "/etc/bash.bashrc"
elif [ ! "x${KSH_VERSION}" = "x" ]; then
  typeset -l HOSTNAME="$(/usr/bin/hostname)"
  profile_d sh
  PS1=$(print '\033]0;${PWD}\n\033[32m${USER}@${HOSTNAME} \033[33m${PWD/${HOME}/~}\033[0m\n$ ')
elif [ ! "x${ZSH_VERSION}" = "x" ]; then
  HOSTNAME="$(/usr/bin/hostname)"
  profile_d zsh
  PS1='(%n@%m)[%h] %~ %% '
elif [ ! "x${POSH_VERSION}" = "x" ]; then
  HOSTNAME="$(/usr/bin/hostname)"
  PS1="$ "
else 
  HOSTNAME="$(/usr/bin/hostname)"
  profile_d sh
  PS1="$ "
fi

if [ -n "$ACLOCAL_PATH" ]
then
  export ACLOCAL_PATH
fi

export PATH MANPATH INFOPATH PKG_CONFIG_PATH USER TMP TEMP PRINTER HOSTNAME PS1 SHELL tmp temp ORIGINAL_TMP ORIGINAL_TEMP ORIGINAL_PATH
unset PATH_SEPARATOR

if [ "$MAYBE_FIRST_START" = "true" ]; then
  sh /usr/bin/regen-info.sh

  if [ -f "/usr/bin/update-ca-trust" ]
  then 
    sh /usr/bin/update-ca-trust
  fi

  clear
  echo
  echo
  echo "###################################################################"
  echo "#                                                                 #"
  echo "#                                                                 #"
  echo "#                   C   A   U   T   I   O   N                     #"
  echo "#                                                                 #"
  echo "#                  This is first start of MSYS2.                  #"
  echo "#       You MUST restart shell to apply necessary actions.        #"
  echo "#                                                                 #"
  echo "#                                                                 #"
  echo "###################################################################"
  echo
  echo
fi
unset MAYBE_FIRST_START

fstab, profileは環境変数書くところ
場所は/msys64/etc以下に存在する。

マウントはprofileが行う
fstabはwindow形式で書かれたpathをbash形式にしてくれる?ショートカット?(←名称不明)みたいなのを作ってくれる。例を見たほうがいいかも。

例えば以下のように記述する。
半角スペースは区切りに使われるので、ディレクトリにスペースが含まれるC:/Program Files/C:/Program\040Files/と記述する。
バックスラッシュスラッシュの区別はないみたいだけど一応ディレクトリの区切りはスラッシュにした。

fstab
C:/tools/Anaconda3/Scripts /conda  # C:/tools/Anaconda3/Scriptsを/condaというショートカットで登録
C:/tools/Anaconda3 /Anaconda3  # パスとショートカットの間には半角スペース
C:/Program\040Files/Sublime\040Text\0403 /subl
C:/Program\040Files/gnuplot/bin/ /gnuplot  # \040は半角スペースの意味。

以上をfstabに書き加えたらprofileのORIGINAL_PATHにショートカットを加える。
区切りは':'

profile

41        # Do not inherit any path configuration but configure a default Windows path
42        # suitable for normal usage with minimal external interference.
43        WIN_ROOT="$(PATH=${MSYS2_PATH} cygpath -Wu)"
44        ORIGINAL_PATH="${WIN_ROOT}/System32:${WIN_ROOT}:${WIN_ROOT}/System32/Wbem:${WIN_ROOT}/System32/WindowsPowerShell/v1.0/:/Anaconda3:/conda:/subl:/gnuplot"   # このへんにあるORIGINAL_PATHにfstabで加えたディレクトリのショートカット加える。区切りは':'
45    esac

MinGW (64bit) + MSYS 環境の構築 (2)

さらに.bash_aliasesにpythonのaliasを追加しておくと、gと打つだけでgitpyと打つだけでpythonipyと打つだけでipython開く。

.bash_aliases
alias g='git'
alias py='python'
alias ipy='ipython'
g='git'
$ g
usage: git [--version] [--help] [-C <path>] [-c name=value]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]

These are common Git commands used in various situations:

start a working area (see also: git help tutorial)
   clone      Clone a repository into a new directory
   init       Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)
   add        Add file contents to the index
   mv         Move or rename a file, a directory, or a symlink
   reset      Reset current HEAD to the specified state
   rm         Remove files from the working tree and from the index

examine the history and state (see also: git help revisions)
   bisect     Use binary search to find the commit that introduced a bug
   grep       Print lines matching a pattern
   log        Show commit logs
   show       Show various types of objects
   status     Show the working tree status

grow, mark and tweak your common history
   branch     List, create, or delete branches
   checkout   Switch branches or restore working tree files
   commit     Record changes to the repository
   diff       Show changes between commits, commit and working tree, etc
   merge      Join two or more development histories together
   rebase     Reapply commits on top of another base tip
   tag        Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)
   fetch      Download objects and refs from another repository
   pull       Fetch from and integrate with another repository or a local branch
   push       Update remote refs along with associated objects

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.

py='python'
$ py

Python 3.5.2 |Anaconda custom (64-bit)| (default, Jul  5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
ipy='ipython'
$ ipy
Python 3.5.2 |Anaconda custom (64-bit)| (default, Jul  5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)]

Type "copyright", "credits" or "license" for more information.

IPython 5.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]:

.inputrc

キーボードショートカットを書いておくところ

.inputrc
# To the extent possible under law, the author(s) have dedicated all 
# copyright and related and neighboring rights to this software to the 
# public domain worldwide. This software is distributed without any warranty. 
# You should have received a copy of the CC0 Public Domain Dedication along 
# with this software. 
# If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. 

# ~/.inputrc: readline initialization file.

# The copy in your home directory (~/.inputrc) is yours, please
# feel free to customise it to create a shell
# environment to your liking.  If you feel a change
# would be benifitial to all, please feel free to send
# a patch to the msys2 mailing list.

# the following line is actually
# equivalent to "\C-?": delete-char
# "\e[3~": delete-char

# VT
# "\e[1~": beginning-of-line
# "\e[4~": end-of-line

# kvt
# "\e[H": beginning-of-line
# "\e[F": end-of-line

# rxvt and konsole (i.e. the KDE-app...)
# "\e[7~": beginning-of-line
# "\e[8~": end-of-line

# VT220
# "\eOH": beginning-of-line
# "\eOF": end-of-line

# Allow 8-bit input/output
# set meta-flag on
# set convert-meta off
# set input-meta on
# set output-meta on
#$if Bash
  # Don't ring bell on completion
  set bell-style none

  # or, don't beep at me - show me
  #set bell-style visible

  # Show all instead of beeping first
  set show-all-if-ambiguous off

  # Filename completion/expansion
  set completion-ignore-case on
  #set show-all-if-ambiguous on

  # Expand homedir name
  #set expand-tilde on

  # Append "/" to all dirnames
  #set mark-directories on
  #set mark-symlinked-directories on

  # visible-stats
  # Append a mark according to the file type in a listing
  set visible-stats off
  set mark-directories on

  # Match all files
  #set match-hidden-files on

  # 'Magic Space'
  # Insert a space character then performs
  # a history expansion in the line
  #Space: magic-space
#$endif

# MSYSTEM is emacs based
$if mode=emacs
  # Common to Console & RXVT
  "\C-?": backward-kill-line         # Ctrl-BackSpace
  "\e[2~": paste-from-clipboard      # "Ins. Key"
  "\e[5~": beginning-of-history      # Page up
  "\e[6~": end-of-history            # Page down

  $if term=msys # RXVT
    "\e[7~": beginning-of-line      # Home Key
    "\e[8~": end-of-line            # End Key
    "\e[11~": display-shell-version # F1
    "\e[15~": re-read-init-file     # F5
    "\e[12~": "Function Key 2"
    "\e[13~": "Function Key 3"
    "\e[14~": "Function Key 4"
    "\e[17~": "Function Key 6"
    "\e[18~": "Function Key 7"
    "\e[19~": "Function Key 8"
    "\e[20~": "Function Key 9"
    "\e[21~": "Function Key 10"
  $else
  # Eh, normal Console is not really cygwin anymore, is it? Using 'else' instead. -mstormo
  # $if term=cygwin # Console
    "\e[1~": beginning-of-line      # Home Key
    "\e[4~": end-of-line            # End Key
    "\e[3~": delete-char      # Delete Key
    "\e\e[C": forward-word      # Alt-Right
    "\e\e[D": backward-word      # Alt-Left
    "\e[1;5C": forward-word   # ctrl + right
    "\e[1;5D": backward-word  # ctrl + left 
    "\e[17~": "Function Key 6"
    "\e[18~": "Function Key 7"
    "\e[19~": "Function Key 8"
    "\e[20~": "Function Key 9"
    "\e[21~": "Function Key 10"
    "\e[23~": "Function Key 11"
  $endif
$endif

デフォルトの設定に"\e[1;5C": forward-word # ctrl + right"\e[1;5D": backward-word # ctrl + leftを加えた。
ctrl+←(→)でワード単位で移動できる。
なぜデフォルトじゃないんだ。
デフォルトではalt+←(→)でワード単位の移動。

参考

15
27
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
15
27