Skip to content

Commit

Permalink
README: update for v0.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Dec 2, 2020
1 parent bbda197 commit 276baf2
Show file tree
Hide file tree
Showing 9 changed files with 387 additions and 32 deletions.
20 changes: 11 additions & 9 deletions README-ja_JP.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
`~/.bashrc` の設定に関しては [節1.3](#set-up-bashrc) を御覧ください。

```bash
# インストール & .bashrc 簡単設定
# インストール & .bashrc 簡単設定 (動かない場合は節1.3を御参照下さい)

git clone --recursive https://github.com/akinomyoga/ble.sh.git
make -C ble.sh install PREFIX=~/.local
Expand Down Expand Up @@ -113,25 +113,27 @@ Make 変数 `DESTDIR` または `PREFIX` が指定されている時、`ble.sh`

`wget` を使う場合:
```console
$ wget https://github.com/akinomyoga/ble.sh/releases/download/v0.3.2/ble-0.3.2.tar.xz
$ tar xJf ble-0.3.2.tar.xz
$ source ble-0.3.2/ble.sh
$ wget https://github.com/akinomyoga/ble.sh/releases/download/v0.3.3/ble-0.3.3.tar.xz
$ tar xJf ble-0.3.3.tar.xz
$ source ble-0.3.3/ble.sh
```
`curl` を使う場合:
```console
$ curl -LO https://github.com/akinomyoga/ble.sh/releases/download/v0.3.2/ble-0.3.2.tar.xz
$ tar xJf ble-0.3.2.tar.xz
$ source ble-0.3.2/ble.sh
$ curl -LO https://github.com/akinomyoga/ble.sh/releases/download/v0.3.3/ble-0.3.3.tar.xz
$ tar xJf ble-0.3.3.tar.xz
$ source ble-0.3.3/ble.sh
```

指定したディレクトリに `ble.sh` を配置するには単に `ble-0.1.7` ディレクトリをコピーします。
```console
$ cp -r ble-0.3.2 /path/to/blesh
$ cp -r ble-0.3.3 /path/to/blesh
```

## 1.3 `.bashrc` に設定する<sup><a id="set-up-bashrc" href="#set-up-bashrc">†</a></sup>

対話シェルで常用する場合には `.bashrc` に設定を行います。以下の様にコードを追加して下さい。
対話シェルで常用する場合には `.bashrc` に設定を行います。
単に `ble.sh``source` して頂くだけでも大抵の場合動作しますが、
より確実に動作させる為には以下の様にコードを記述します。
```bash
# bashrc

Expand Down
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ For detailed descriptions, see [Sec 1.1](#get-from-source) and [Sec 1.2](#get-fr
[Sec 1.3](#set-up-bashrc) for the setup of your `~/.bashrc`.

```bash
# Quick INSTALL to BASHRC
# Quick INSTALL to BASHRC (If this doesn't work, please follow Sec 1.3)

git clone --recursive https://github.com/akinomyoga/ble.sh.git
make -C ble.sh install PREFIX=~/.local
Expand Down Expand Up @@ -113,25 +113,26 @@ To set up `.bashrc` see [Sec. 1.3](#set-up-bashrc).

With `wget`:
```bash
wget https://github.com/akinomyoga/ble.sh/releases/download/v0.3.2/ble-0.3.2.tar.xz
tar xJf ble-0.3.2.tar.xz
source ble-0.3.2/ble.sh
wget https://github.com/akinomyoga/ble.sh/releases/download/v0.3.3/ble-0.3.3.tar.xz
tar xJf ble-0.3.3.tar.xz
source ble-0.3.3/ble.sh
```
With `curl`:
```bash
curl -LO https://github.com/akinomyoga/ble.sh/releases/download/v0.3.2/ble-0.3.2.tar.xz
tar xJf ble-0.3.2.tar.xz
source ble-0.3.2/ble.sh
curl -LO https://github.com/akinomyoga/ble.sh/releases/download/v0.3.3/ble-0.3.3.tar.xz
tar xJf ble-0.3.3.tar.xz
source ble-0.3.3/ble.sh
```

If you want to place `ble.sh` in a specific directory, just copy the directory:
```bash
cp -r ble-0.3.2 /path/to/blesh
cp -r ble-0.3.3 /path/to/blesh
```

## 1.3 Set up `.bashrc`<sup><a id="set-up-bashrc" href="#set-up-bashrc">†</a></sup>

If you want to load `ble.sh` by default in interactive sessions of `bash`, add the following codes to your `.bashrc` file:
If you want to load `ble.sh` by default in interactive sessions of `bash`, usually one can just source `ble.sh` in `~/.bashrc`,
but more reliable way is to add the following codes to your `.bashrc` file:
```bash
# bashrc

Expand Down
17 changes: 12 additions & 5 deletions generate-release-note.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

fname_changelog=changelog.txt
fname_changelog=memo/ChangeLog.md

function read-arguments {
while (($#)); do
Expand Down Expand Up @@ -33,23 +33,26 @@ function process {
local c=${commit_pair#*:}

local result=
[[ $b ]] && result=$(sed -n "s/$b/$a (master: $b)/p" "$fname_changelog")
[[ $b ]] && result=$(awk '
sub(/^##+ +/, "") { heading = "[" $1 "] "; next; }
sub(/\y'"$b"'\y/, "'"$a (master: $b)"'") {print heading $0;}
' "$fname_changelog")
if [[ $result ]]; then
echo "$result"
elif [[ $c ]]; then
echo "- $c $a (master: ${b:-N/A}) ■NOT-FOUND■"
else
echo "■not found $a"
fi
done
done | tac
}

function find-commit-pairs {
{
echo __MODE_HEAD__
git log --format=format:'%h%s' --date-order --abbrev-commit "$1"..HEAD; echo
git log --format=format:'%h%s' --date-order --abbrev-commit "$1"; echo
echo __MODE_MASTER__
git log --format=format:'%h%s' --date-order --abbrev-commit "${2:-master}"; echo
git log --format=format:'%h%s' --date-order --abbrev-commit master; echo
} | awk -F '' '
/^__MODE_HEAD__$/ {
mode = "head";
Expand Down Expand Up @@ -78,3 +81,7 @@ function find-commit-pairs {

IFS=$'\n' eval 'commit_pairs=($(find-commit-pairs "$@"))'
process "${commit_pairs[@]}"

# 使い方
# ./generate-release-note.sh v0.3.2..v0.3.3
#
4 changes: 2 additions & 2 deletions lib/core-complete.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6168,9 +6168,9 @@ function ble/complete/action:cdpath/init-menu-item {
function ble/complete/action:cdpath/get-desc {
local sgr0=$_ble_term_sgr0 sgr1= sgr2=
local g ret g1 g2
ble/syntax/highlight/getg-from-filename "$DATA$CAND"; local g1=$g
ble/syntax/highlight/getg-from-filename "$DATA$CAND"; g1=$g
[[ $g1 ]] || { ble/color/face2g filename_warning; g1=$ret; }
((g2=g^_ble_color_gflags_Revert))
((g2=g1^_ble_color_gflags_Revert))
ble/color/g2sgr "$g1"; sgr1=$ret
ble/color/g2sgr "$g2"; sgr2=$ret
ble/string#escape-for-display "$DATA$CAND" sgr1="$sgr2":sgr0="$sgr1"
Expand Down
14 changes: 12 additions & 2 deletions lib/core-syntax.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
#%[release = 0]
#%m main (

function ble/syntax/util/is-directory {
local path=$1
# Note: #D1168 Cygwin では // で始まるパスの判定は遅い
if [[ ( $OSTYPE == cygwin || $OSTYPE == msys ) && $path == //* ]]; then
[[ $path == // ]]
else
[[ -d $path ]]
fi
}

## 関数 ble/syntax/urange#update prefix p1 p2
## 関数 ble/syntax/wrange#update prefix p1 [p2]
## @param[in] prefix
Expand Down Expand Up @@ -5873,7 +5883,7 @@ function ble/syntax/highlight/cmdtype1 {
((type=ATTR_ERR))
fi ;;
(*)
if [[ -d "$cmd" ]] && shopt -q autocd &>/dev/null; then
if [[ -d $cmd ]] && shopt -q autocd &>/dev/null; then
((type=ATTR_CMD_DIR))
else
((type=ATTR_ERR))
Expand Down Expand Up @@ -6326,7 +6336,7 @@ function ble/syntax/progcolor/word:default/.highlight-pathspec {
local epath=${path[ipath]} espec=${spec[ipath]}
local g=d

if [[ -d $epath ]]; then
if ble/syntax/util/is-directory "$epath"; then
local type
ble/syntax/highlight/filetype "$epath" &&
ble/syntax/attr2g "$type"
Expand Down
3 changes: 2 additions & 1 deletion memo/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!---------------------------------------------------------------------------->
# ble-0.4.0-devel2

2020-01-12 -- (#D1215... ) c74abc5...
2020-01-12 -- 2020-12-02 (`#D1215`...`#D1426`) c74abc5...

## New features

Expand Down Expand Up @@ -125,6 +125,7 @@
- global: work around Bash-4.4 `return` in trap handlers `#D1334` aa09d15
- util (`ble-stackdump`): fix a shift of line numbers `#D1337` a14b72f d785b64
- edit (`ble-bind -x`): check range of `READLINE_{POINT,MARK}` `#D1339` efe1e81
- main: fix a bug that `~/.config/blesh/init.sh` is not detected (GitHub #53 by rux616) 61f9e10
- util (`ble/string#to{upper,lower}`): work around `LC_COLLATE=en_US.utf8` (test-util) `#D1341` 1f6b44e `#D1355` 4da6103 5f0d49f
- util (encoding, keyseq): fix miscelleneous encoding bugs (test-util) 435bd16
- `ble/util/c2keyseq`: work around bash ambiguous keyseq `\M-\C-\\`
Expand Down
151 changes: 151 additions & 0 deletions memo/D1405.extract-man.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
#!/bin/bash

function ble/complete/mandb/search-file/.check {
local path=$1
if [[ $path && -s $path ]]; then
ret=$path
return 0
else
return 1
fi
}
function ble/complete/mandb/search-file {
local command=$1

# Try "man -w" first
ble/complete/mandb/search-file/.check "$(man -w "$command" 2>/dev/null)" && return

local manpath=${MANPATH:-/usr/share/man:/usr/local/share/man:/usr/local/man}
ble/string#split manpath : "$manpath"
local path
for path in "${manpath[@]}"; do
ble/complete/mandb/search-file/.check "$path/man1/$man.1.gz" && return
ble/complete/mandb/search-file/.check "$path/man1/$man.1" && return
ble/complete/mandb/search-file/.check "$path/man1/$man.8.gz" && return
ble/complete/mandb/search-file/.check "$path/man1/$man.8" && return
done
return 1
}

ble/complete/mandb/search-file "${1:-grep}" || return 1
path=$ret

if [[ $ret == *.gz ]]; then
gzip -cd "$path" #/usr/share/man/man1/grep.1.gz
else
cat "$path"
fi |
awk '
BEGIN {
g_key = "";
g_desc = "";
print ".TH __ble_ignore__ 1 __ble_ignore__ __ble_ignore__";
print ".ll 9999"
}
function flush_topic() {
if (g_key == "") return;
print "__ble_key__";
print ".TP";
print g_key;
print "";
print "__ble_desc__";
print "";
print g_desc;
print "";
g_key = "";
g_desc = "";
}
/^\.TP\y/ { flush_topic(); mode = "key"; next; }
/^\.(SS|SH)\y/ { flush_topic(); next; }
mode == "key" {
g_key = $0;
g_desc = "";
mode = "desc";
next;
}
mode == "desc" {
if (g_desc != "") g_desc = g_desc "\n";
g_desc = g_desc $0;
}
END { flush_topic(); }
' | groff -Tutf8 -man | awk '
function process_pair(name, desc) {
if (!(g_name ~ /^-/)) return;
# FS (\034) は ble.sh で内部使用の為除外する。
sep = "\x1b[1;91m:\x1b[m";
#sep = "\034";
if (g_name ~ /\034/) return;
gsub(/\034/, "\x1b[7m^\\\x1b[27m", desc);
n = split(name, names, /,[[:space:]]*/);
sub(/(\. |; ).*/, ".", desc);
for (i = 1; i <= n; i++) {
name = names[i];
insert_suffix = " ";
menu_suffix = "";
if (match(name, /[[ =]/)) {
m = substr(name, RSTART, 1);
if (m == "=") {
insert_suffix = "=";
} else if (m == "[") {
insert_suffix = "";
}
menu_suffix = substr(name, RSTART);
name = substr(name, 1, RSTART - 1);
}
printf("%s" sep "%s" sep "%s" sep "%s\n", name, menu_suffix, insert_suffix, desc);
}
}
function flush_pair() {
if (g_name == "") return;
if (g_name ~ /^-/) {
process_pair(g_name, g_desc);
#print "\x1b[1;94m" g_name "\x1b[0m";
#print g_desc;
#print "";
}
g_name = "";
g_desc = "";
}
sub(/^[[:space:]]*__ble_key__/, "", $0) {
flush_pair();
mode = "key";
}
sub(/^[[:space:]]*__ble_desc__/, "", $0) {
mode = "desc";
}
mode == "key" {
line = $0;
gsub(/\x1b\[[ -?]*[@-~]/, "", line); # CSI seq
gsub(/\x1b[ -/]*[0-~]/, "", line); # ESC seq
gsub(/\x0E/, "", line);
gsub(/\x0F/, "", line);
gsub(/^[[:space:]]*|[[:space:]]*$/, "", line);
#gsub(/[[:space:]]+/, " ", line);
if (line == "") next;
if (g_name != "") g_name = g_name " ";
g_name = g_name line;
}
mode == "desc" {
line = $0;
gsub(/^[[:space:]]*|[[:space:]]*$/, "", line);
#gsub(/[[:space:]]+/, " ", line);
if (line == "") {
if (g_desc != "") mode = "";
next;
}
if (g_desc != "") g_desc = g_desc " ";
g_desc = g_desc line;
}
END { flush_pair(); }
' | sort -k 1
Loading

0 comments on commit 276baf2

Please sign in to comment.