{"id":165,"date":"2012-01-06T00:57:44","date_gmt":"2012-01-06T08:57:44","guid":{"rendered":"http:\/\/h2plus.biz\/hiromitsu\/?p=165"},"modified":"2013-09-17T11:54:19","modified_gmt":"2013-09-17T18:54:19","slug":"%e6%a8%99%e6%ba%96%e5%87%ba%e5%8a%9b%e3%82%92%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89%e5%b1%a5%e6%ad%b4%e3%81%ab%e8%bf%bd%e5%8a%a0%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/h2plus.biz\/hiromitsu\/entry\/165","title":{"rendered":"\u6a19\u6e96\u51fa\u529b\u3092\u30b3\u30de\u30f3\u30c9\u5c65\u6b74\u306b\u8ffd\u52a0\u3059\u308b"},"content":{"rendered":"<p><a href=\"http:\/\/h2plus.biz\/hiromitsu\/entry\/63\">\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u3092vi\u30e2\u30fc\u30c9\u3067\u7de8\u96c6\u3059\u308b<\/a>\u306e\u30a8\u30f3\u30c8\u30ea\u3067\u300c\u305d\u308c\u3069\u3046\u3084\u3093\u306e\uff01\uff1f\u300d\u3068\u8a0a\u3044\u3066\u304d\u305f\u77e5\u4eba\u304b\u3089\u3001\u5f8c\u65e5\u3053\u3093\u306a\u30e1\u30fc\u30eb\u3092\u3082\u3089\u3063\u305f\u3002<\/p>\n<blockquote><p>vi\u30e2\u30fc\u30c9\u306b\u3057\u3066\u305d\u306e\u5ef6\u9577\u4e0a\u3067\u30b3\u30de\u30f3\u30c9\u306e\u7d50\u679c\u306b\u5bfe\u3057\u3066prompt\u3067\u7de8\u96c6\uff08\uff1f\uff09\u307f\u305f\u3044\u306e\u3063\u3066\u3067\u304d\u308b\u306e\u3067\u3059\u304b\u306d\uff1f<\/p>\n<p>\u4f8b\u3048\u3070<\/p>\n<pre>\r\n$ cat somefile.txt  # \u3053\u308c\u306b\u30d5\u30a1\u30a4\u30eb\u540d\u304c\u5e7e\u3064\u304b\u5165\u3063\u3066\u3044\u308b\r\nsrc\/file1.txt\r\nsrc\/file2.txt\r\n<\/pre>\n<p>\u3067\u3053\u3053\u3067ESC\u3092\u62bc\u3059\u3068vi\u30e2\u30fc\u30c9\u306b\u306a\u3063\u3066<code>j<\/code>\u3068\u304b<code>k<\/code>\u3068\u304b\u3067<code>file1.txt<\/code>\u3068<code>file2.txt<\/code>\u304c\u30c1\u30e9\u30c1\u30e9\u3068\u898b\u3048\u308b\u3002<br \/>\n\u6700\u7d42\u7684\u306b\u306f<code>i<\/code>\u3068\u304b\u4f7f\u3063\u3066<\/p>\n<pre>$ vi src\/file2.txt<\/pre>\n<p>\u3068\u304b\u304c\u3071\u3063\u3068\u3067\u304d\u305f\u308a\u3059\u308b\u3068\u3044\u3044\u306a\u30fc\u3068\u601d\u3063\u3066\u3044\u308b\u3002<\/p><\/blockquote>\n<p><!--more--><br \/>\n\u4eca\u307e\u3067\u305d\u3046\u3044\u3046\u767a\u60f3\u3092\u3057\u305f\u3053\u3068\u304c\u306a\u304b\u3063\u305f\u304c\u3001\u6b32\u3057\u3044\u30b7\u30c1\u30e5\u30a8\u30fc\u30b7\u30e7\u30f3\u306f\u78ba\u304b\u306b\u3042\u308a\u305d\u3046\u3060\u3002<\/p>\n<p>\u6a19\u6e96\u51fa\u529b\u306e\u7d50\u679c\u3092vim\u3067\u7de8\u96c6\u3059\u308b\u3053\u3068\u3092\u524d\u63d0\u306b\u3059\u308b\u306a\u3089\u3070\u3001<\/p>\n<pre>\r\n$ cat somefile.txt | vim -R -\r\n<\/pre>\n<p>\u3068\u3084\u3063\u3066\u3001vim\u5185\u3067<code>src\/file1.txt<\/code>\u306b\u30ab\u30fc\u30bd\u30eb\u3092\u5408\u308f\u305b\u3066<\/p>\n<pre>\r\n<u>s<\/u>rc\/file1.txt\r\nsrc\/file2.txt\r\n<\/pre>\n<p><code>gf<\/code>\u3068\u30bf\u30a4\u30d7\u3059\u308c\u3070\u3001<code>src\/file1.txt<\/code>\u304c\u305d\u306e\u307e\u307e\u7de8\u96c6\u53ef\u80fd\u306b\u306a\u308b\u3002<\/p>\n<p>\u86c7\u8db3\u3060\u304c\u3001<code>somefile.txt<\/code>\u304c\u4eee\u306b<\/p>\n<pre>\r\nsrc\r\nsrc\/file1.txt\r\nsrc\/file2.txt\r\n<\/pre>\n<p>\u3068\u306a\u3063\u3066\u3044\u3066\u3001<code>src<\/code>\u306b\u30ab\u30fc\u30bd\u30eb\u3092\u5408\u308f\u305b\u3066<code>gf<\/code>\u3068\u30bf\u30a4\u30d7\u3059\u308c\u3070\u3001vim\u306e\u4e2d\u3067\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30d3\u30e5\u30fc\u304c\u8868\u793a\u3055\u308c\u308b\u3002<br \/>\n<img src=\"http:\/\/h2plus.biz\/hiromitsu\/wp-content\/uploads\/2012\/01\/vim.png\" alt=\"\" title=\"vim\" width=\"610\" class=\"aligncenter size-full wp-image-170\" srcset=\"https:\/\/h2plus.biz\/hiromitsu\/wp-content\/uploads\/2012\/01\/vim.png 665w, https:\/\/h2plus.biz\/hiromitsu\/wp-content\/uploads\/2012\/01\/vim-300x147.png 300w\" sizes=\"(max-width: 665px) 100vw, 665px\" \/><br \/>\n\u3082\u3061\u308d\u3093\u3001\u30ab\u30fc\u30bd\u30eb\u306e\u79fb\u52d5\u306fvim\u306e\u30ad\u30fc\u30d0\u30a4\u30f3\u30c9\u3002\u30d5\u30a1\u30a4\u30eb\u540d\u3084\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u540d\uff08<code>..\/<\/code>\u3082\u542b\u3080\uff09\u306b\u30ab\u30fc\u30bd\u30eb\u3092\u5408\u308f\u305b\u3066Enter\u3092\u62bc\u305b\u3070\u3001\u305d\u306e\u30d5\u30a1\u30a4\u30eb\u3084\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u958b\u304f\u3053\u3068\u304c\u3067\u304d\u308b\u3002\u5225\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u304f\u3068\u304d\u306b\u3001\u3044\u3061\u3044\u3061<code>:q<\/code>\u30b3\u30de\u30f3\u30c9\u3067vim\u3092\u629c\u3051\u3066\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u79fb\u52d5\u3057\u306a\u304f\u3066\u6e08\u3080\u3057\u3001<code>:e<\/code>\u30b3\u30de\u30f3\u30c9\u3084<code>:sp<\/code>\u30b3\u30de\u30f3\u30c9\u3067\u5225\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u304f\u3068\u304d\u3082\u3001\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u540d\u307e\u3067\u88dc\u5b8c\u3057\u305f\u72b6\u614b\u3067Enter\u3092\u62bc\u305b\u3070\u3001\u540c\u3058\u3088\u3046\u306b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30d3\u30e5\u30fc\u304c\u4f7f\u3048\u308b\u3002<\/p>\n<p>\u3055\u3066\u3001\u8a71\u3092\u623b\u305d\u3046\u3002<\/p>\n<p>\u30b3\u30de\u30f3\u30c9\u5c65\u6b74\u304c\u4fdd\u5b58\u3055\u308c\u3066\u3044\u308b\u5834\u6240\u3068\u3057\u3066\u771f\u3063\u5148\u306b\u601d\u3044\u3064\u304f\u306e\u304c<code>~\/.bash_history<\/code>\u30d5\u30a1\u30a4\u30eb\u3002\u6a19\u6e96\u51fa\u529b\u306e\u7d50\u679c\u3092<code>~\/.bash_history<\/code>\u306b\u8ffd\u8a18\u3059\u308c\u3070\u5b9f\u73fe\u3067\u304d\u308b\u304b\u3082\u3068\u601d\u3063\u305f\u304c\u3001<code>~\/.bash_history<\/code>\u306f\u30ed\u30b0\u30a2\u30a6\u30c8\u6642\uff08\u30bf\u30fc\u30df\u30ca\u30eb\u3067<code>exit<\/code>\u3057\u305f\u6642\uff09\u306b\u66f8\u304d\u51fa\u3055\u308c\u3066\u3001\u30ed\u30b0\u30a4\u30f3\u6642\uff08\u30bf\u30fc\u30df\u30ca\u30eb\u3092\u958b\u3044\u305f\u6642\uff09\u306b\u8aad\u307f\u8fbc\u307e\u308c\u308b\u3002\u30bb\u30c3\u30b7\u30e7\u30f3\u4e2d\u306e\u30b3\u30de\u30f3\u30c9\u5c65\u6b74\u306fbash\u306e\u30e1\u30e2\u30ea\u5185\u3067\u4fdd\u6301\u3055\u308c\u3066\u3044\u3066\u3001\u3069\u3053\u304b\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u66f8\u304d\u51fa\u3055\u308c\u3066\u3044\u308b\u308f\u3051\u3067\u306f\u306a\u3044\u3002<\/p>\n<p>history\u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u3063\u3066\u30b3\u30de\u30f3\u30c9\u5c65\u6b74\u306e\u66f8\u304d\u51fa\u3057\u3001\u8aad\u307f\u8fbc\u307f\u306f\u3067\u304d\u308b\u304c\u3001\u76f4\u63a5\u7de8\u96c6\u3067\u304d\u308b\u3088\u3046\u306a\u30aa\u30d7\u30b7\u30e7\u30f3\u306f\u306a\u3044\u3002<\/p>\n<pre>\r\n$ cat somefile.txt > tmp\r\n$ history -r tmp\r\n$ rm -f tmp\r\n<\/pre>\n<p>\u3068\u3084\u308c\u3070\u3001\u3068\u308a\u3042\u3048\u305a\u30b3\u30de\u30f3\u30c9\u5c65\u6b74\u306b\u8ffd\u8a18\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u308b\u304c\u3001\u3044\u3061\u3044\u3061\u30c6\u30f3\u30dd\u30e9\u30ea\u30d5\u30a1\u30a4\u30eb\u3092\u624b\u52d5\u3067\u4f5c\u3063\u3066\u6d88\u3057\u3066\u3068\u3084\u308b\u306e\u306f\u975e\u52b9\u7387\u7684\u3002<code>~\/.bashrc<\/code>\u3042\u305f\u308a\u306b\u30b5\u30d6\u30eb\u30fc\u30c1\u30f3\u5316\u3057\u3066\u3057\u307e\u3046\u306e\u304c\u5f97\u7b56\u3060\u308d\u3046\u3002<\/p>\n<p>\u3067\u3001<code>addhist<\/code>\u3068\u3044\u3046\u30b5\u30d6\u30eb\u30fc\u30c1\u30f3\u3092\u66f8\u3044\u3066\u307f\u305f\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\naddhist()\r\n{\r\n\tlocal tmpfile=`mktemp`\r\n\twhile read cmd\r\n\tdo\r\n\t\t[ -n &quot;$cmd&quot; ] &amp;&amp; echo $cmd &gt;&gt; $tmpfile\r\n\tdone\r\n\thistory -r $tmpfile\r\n\trm -f $tmpfile\r\n}\r\n<\/pre>\n<p>\u3068\u308a\u307e<code>~\/addhist<\/code>\u3068\u3057\u3066\u4fdd\u5b58\u3057\u3066\u8a66\u3057\u3066\u307f\u308b\u3002<\/p>\n<pre>\r\n$ . ~\/addhist\r\n$ history -c\r\n$ cat somefile.txt | addhist\r\n$ history\r\n1 cat somefile.txt | addhist\r\n2 history\r\n<\/pre>\n<p>\u3042\u308c\uff1f\u304a\u304b\u3057\u3044\u306a\u3002<br \/>\n\u30c7\u30d0\u30c3\u30b0\u7528\u306b\u4e00\u884c\u8ffd\u52a0\u3002<\/p>\n<pre class=\"brush: bash; highlight: [10]; title: ; notranslate\" title=\"\">\r\naddhist()\r\n{\r\n\tlocal tmpfile=`mktemp`\r\n\twhile read cmd\r\n\tdo\r\n\t\t[ -n &quot;$cmd&quot; ] &amp;&amp; echo $cmd &gt;&gt; $tmpfile\r\n\tdone\r\n\thistory -r $tmpfile\r\n\trm -f $tmpfile\r\n\thistory\r\n}\r\n<\/pre>\n<pre>\r\n$ . ~\/addhist\r\n$ history -c\r\n$ cat somefile.txt | addhist\r\nsrc\/file1.txt\r\nsrc\/file2.txt\r\n<\/pre>\n<p><code>addhist<\/code>\u306e\u4e2d\u3067\u306f\u3061\u3083\u3093\u3068\u5c65\u6b74\u306b\u8ffd\u52a0\u3055\u308c\u3066\u3044\u308b\u3002<\/p>\n<p>\u3042\uff5e\uff01\u30d1\u30a4\u30d7\u3067\u6e21\u3057\u3066\u308b\u304b\u3089addhist\u304c\u5225\u30bb\u30c3\u30b7\u30e7\u30f3\u306b\u306a\u3063\u3066\u3057\u307e\u3063\u3066\u308b\u308f\u3051\u306d\u3002\u547c\u3073\u51fa\u3057\u5143\u306e\u30bb\u30c3\u30b7\u30e7\u30f3\u306b\u306f\u4f55\u306e\u5f71\u97ff\u3082\u306a\u3044\u3068\u3002<code>addhist<\/code>\u5185\u3067\u66f8\u304d\u8fbc\u3093\u3060history\u3092export\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u308b\u306e\u3060\u308d\u3046\u304b&#8230;\u983c\u308a\u306eGoogle\u5148\u751f\u304c\u51fa\u3057\u305f\u7b54\u3048\u304c\u30b3\u30ec\u3060\u3002<\/p>\n<p><del datetime=\"2012-08-21T09:01:47+00:00\">Real-time history export amongst Bash terminal windows<\/del>\uff082012\/08\/21 \u30ea\u30f3\u30af\u5207\u308c\uff09<\/p>\n<p>\u306a\u308b\u307b\u3069\u3002<code>$PROMPT_COMMAND<\/code>\u3092\u4f7f\u3063\u3066\u3001<code>$HISTFILE<\/code>\uff08\uff1d<code>~\/.bash_history<\/code>\uff09\u7d4c\u7531\u3067\u5168\u30bb\u30c3\u30b7\u30e7\u30f3\u3067\u540c\u671f\u3055\u305b\u308b\u306e\u306d\u3002\u3053\u308c\u304c\u3067\u304d\u308b\u306a\u3089\u3001\u3082\u3046<code>addhist<\/code>\u306f\u5b58\u5728\u81ea\u4f53\u304c\u5426\u5b9a\u3055\u308c\u3066\u3057\u307e\u3046\u3088\u3046\u306a&#8230;\u3002<\/p>\n<p>\u3072\u3068\u307e\u305a\u3001~\/.bashrc\u306b\u4ee5\u4e0b\u306e\u6570\u884c\u3092\u8ffd\u8a18\u3057\u3066\u3001<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nshopt -s histappend\r\nexport HISTCONTROL=ignoreboth:erasedups\r\nexport HISTSIZE=100000\r\nexport HISTFILESIZE=$HISTSIZE\r\nexport PROMPT_COMMAND=&quot;history -a; history -c; history -r; $PROMPT_COMMAND&quot;\r\n<\/pre>\n<p>bash\u306e\u5225\u30bb\u30c3\u30b7\u30e7\u30f3\u3092\u958b\u304f\u3002<code>$PROMPT_COMMAND<\/code>\u304c\u518d\u5e30\u3057\u3066\u308b\u306e\u3067\u3001\u30c6\u30b9\u30c8\u6bb5\u968e\u3067\u306f<code>.<\/code>\uff08\u30c9\u30c3\u30c8\uff09\u30b3\u30de\u30f3\u30c9\u3067\u8aad\u307f\u8fbc\u3080\u3068\u9762\u5012\u306a\u3053\u3068\u306b\u306a\u308b\u3002<\/p>\n<pre>\r\n$ bash\r\n$ &gt; $HISTFILE\r\n$ history\r\n1 &gt; $HISTFILE\r\n2 history\r\n$ cat somefile.txt &gt;&gt; $HISTFILE\r\n$ history\r\n1 &gt; $HISTFILE\r\n2 src\/file1.txt\r\n3 src\/file2.txt\r\n4 cat somefile.txt &gt;&gt; $HISTFILE\r\n5 history\r\n<\/pre>\n<p>\u304a\u304a\u3001\u671f\u5f85\u901a\u308a<code>somefile.txt<\/code>\u306e\u5185\u5bb9\u304chistory\u306b\u8ffd\u52a0\u3067\u304d\u305f\u3002<br \/>\n\u3067\u3082\u500b\u4eba\u7684\u306b\u306f<\/p>\n<pre>\r\n$ cat somefile.txt &gt;&gt; $HISTFILE\r\n<\/pre>\n<p>\u3068\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3092\u4f7f\u3046\u3088\u308a\u3001<code>addhist<\/code>\u307f\u305f\u3044\u306b\u30d1\u30a4\u30d7\u3067\u3064\u306a\u3050\u65b9\u304c\u3044\u3044\u3002\u7406\u7531\u306f2\u3064\u3042\u3063\u3066\u30011\u3064\u306f<code>$HISTFILE<\/code>\u306e\u30ad\u30fc\u30b9\u30c8\u30ed\u30fc\u30af\u304cShift\u62bc\u3057\u3063\u3071\u306a\u3057\u3067\u75b2\u308c\u308b\u3002\u3082\u30461\u3064\u306f\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u306e<code>&gt;&gt;<\/code>\u3092\u3046\u3063\u304b\u308a<code>&gt;<\/code>\u3068typo\u3057\u3066\u3057\u307e\u3046\u3068\u5c65\u6b74\u304c\u304d\u308c\u3044\u306b\u6d88\u3048\u3066\u3057\u307e\u3046\u3068\u3044\u3046\u60b2\u60e8\u306a\u7d50\u679c\u306b\u306a\u308b\u3002\u3053\u308c\u306f\u7d50\u69cb\u3042\u308a\u304c\u3061\u306a\u30d1\u30bf\u30fc\u30f3\u304b\u3068\u3002<\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u7d42\u76e4\u306b\u304d\u3066<code>addhist<\/code>\u5fa9\u6d3b\uff01<br \/>\n\u6700\u7d42\u7684\u306b<code>~\/.bashrc<\/code>\u306b\u8ffd\u8a18\u3057\u305f\u30b3\u30fc\u30c9\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nshopt -s histappend\r\nexport HISTCONTROL=ignoreboth:erasedups\r\nexport HISTSIZE=100000\r\nexport HISTFILESIZE=$HISTSIZE\r\n\r\naddhist()\r\n{\r\n\twhile read cmd\r\n\tdo\r\n\t\t[ -n &quot;$cmd&quot; ] &amp;&amp; echo $cmd &gt;&gt; $HISTFILE\r\n\tdone\r\n}\r\n\r\nexport PROMPT_COMMAND=&quot;history -a; history -c; history -r; $PROMPT_COMMAND&quot;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u3092vi\u30e2\u30fc\u30c9\u3067\u7de8\u96c6\u3059\u308b\u306e\u30a8\u30f3\u30c8\u30ea\u3067\u300c\u305d\u308c\u3069\u3046\u3084\u3093\u306e\uff01\uff1f\u300d\u3068\u8a0a\u3044\u3066\u304d\u305f\u77e5\u4eba\u304b\u3089\u3001\u5f8c\u65e5\u3053\u3093\u306a\u30e1\u30fc\u30eb\u3092\u3082\u3089\u3063\u305f\u3002 vi\u30e2\u30fc\u30c9\u306b\u3057\u3066\u305d\u306e\u5ef6\u9577\u4e0a\u3067\u30b3\u30de\u30f3\u30c9\u306e\u7d50\u679c\u306b\u5bfe\u3057\u3066prompt\u3067\u7de8\u96c6\uff08\uff1f\uff09\u307f\u305f\u3044\u306e\u3063\u3066\u3067\u304d\u308b\u306e\u3067\u3059 <a href='https:\/\/h2plus.biz\/hiromitsu\/entry\/165' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[26],"tags":[103,29,102,99,98,94,92,93,100,101,35,49],"_links":{"self":[{"href":"https:\/\/h2plus.biz\/hiromitsu\/wp-json\/wp\/v2\/posts\/165"}],"collection":[{"href":"https:\/\/h2plus.biz\/hiromitsu\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/h2plus.biz\/hiromitsu\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/h2plus.biz\/hiromitsu\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/h2plus.biz\/hiromitsu\/wp-json\/wp\/v2\/comments?post=165"}],"version-history":[{"count":0,"href":"https:\/\/h2plus.biz\/hiromitsu\/wp-json\/wp\/v2\/posts\/165\/revisions"}],"wp:attachment":[{"href":"https:\/\/h2plus.biz\/hiromitsu\/wp-json\/wp\/v2\/media?parent=165"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/h2plus.biz\/hiromitsu\/wp-json\/wp\/v2\/categories?post=165"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/h2plus.biz\/hiromitsu\/wp-json\/wp\/v2\/tags?post=165"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}