Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
8d9d75b
refactor: update error handling and improve documentation across the …
tamada Dec 23, 2025
7de7525
docs: add comprehensive README for sibling CLI with usage examples an…
tamada Dec 23, 2025
e8074d3
update version to 2.0.3, ready to publish v2.0.3
actions-user Dec 23, 2025
0384fa2
fix: correct spelling in comments and update keywords in Cargo.toml f…
tamada Jan 6, 2026
2521028
refactor: simplify imports and update type usage in CLI and library
tamada Jan 6, 2026
2109f1f
refactor: update path handling to use references instead of owned typ…
tamada Jan 6, 2026
1f73dd4
refactor: replace print_error function with direct error printing in …
tamada Jan 7, 2026
1e44817
ci: update build process to include clippy checks and refine coverage…
tamada Jan 21, 2026
7f45514
refactor: reorganize imports, update test data paths, and add .nodata…
tamada Jan 21, 2026
7fc6ee4
feat: add logging functionality and improve directory navigation in CLI
tamada Jan 22, 2026
0c500fb
refactor: simplify result_string logic by removing redundant conditio…
tamada Jan 22, 2026
6503a41
fix: update current_dir check to use Path::new for consistency
tamada Jan 22, 2026
57ab0e9
fix: update path comparison in perform_sibling to use std::path::Path
tamada Jan 22, 2026
c160dfd
feat: add .nodata files for directories with spaces and multibyte cha…
tamada Jan 22, 2026
b757f73
fix: enhance logging initialization and improve clippy command in CI
tamada Jan 22, 2026
42cdd72
feat: add logging options and improve command-line help across comple…
tamada Jan 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ jobs:
rustup update stable

- name: build
run: cargo build --release
run: |
cargo clippy --all-targets --all-features -- -D warnings
cargo build --release

- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
if: matrix.os == 'ubuntu-latest'

- name: Generate code coverage
run: cargo llvm-cov --all-features --workspace --lcov --output-path coverage.lcov
run: cargo llvm-cov --workspace --lcov --output-path coverage.lcov
if: matrix.os == 'ubuntu-latest'

- name: coveralls
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ members = [ "lib", "cli" ]
resolver = "3"

[workspace.package]
version = "2.0.2"
version = "2.0.3"
repository = "https://github.com/tamada/sibling"
homepage = "https://tamada.github.io/sibling"
readme = "README.md"
Expand Down
46 changes: 8 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Rust Report Card](https://rust-reportcard.xuri.me/badge/github.com/tamada/sibling)](https://rust-reportcard.xuri.me/report/github.com/tamada/sibling)

[![License](https://img.shields.io/badge/License-WTFPL-information.svg)](https://github.com/tamada/sibling/blob/master/LICENSE)
[![Version](https://img.shields.io/badge/Version-2.0.0--beta--2-information.svg)](https://github.com/tamada/sibling/releases/tag/v2.0.0-beta-2)
[![Version](https://img.shields.io/badge/Version-2.0.3-information.svg)](https://github.com/tamada/sibling/releases/tag/v2.0.3)

get the next/previous sibling directory name.

Expand Down Expand Up @@ -47,26 +47,6 @@ The `cdnext` and the `cdprev` allow the integer argument to repeat the traversin

## :runner: Usage

```sh
get next/previous sibling directory name.

Usage: sibling [OPTIONS] [DIR]

Arguments:
[DIR] the directory for listing the siblings [default: .]

Options:
-a, --absolute print the directory name in the absolute path
-l, --list list the sibling directories
-p, --progress print the progress of traversing directories
-P, --parent print parent directory, when no more sibling directories
-s, --step <COUNT> specify the number of times to execute sibling [default: 1]
-t, --type <TYPE> specify the nexter type [default: next]
[possible values: first, last, previous, next, random, keep]
-h, --help Print help
-V, --version Print version
```

`sibling` prints the next directory name with 0 status code.
The next directory is decided by the traversing type. Available values are: `next`, `previous`, `first`, `last`, `keep` and `random`, default is `next`.

Expand All @@ -78,7 +58,7 @@ After visiting the final directory, the `sibling` prints nothing and exits with

Install `sibling` via [Homebrew](https://brew.sh), simply run:

```sh
```bash
brew tap tamada/brew
brew install sibling
```
Expand All @@ -87,7 +67,7 @@ And put the following snipeets into your shell profile (e.g., `.bash_profile`, o
The `--init` option accepts only `bash`.
Other shell scripts are not supported, yet.

```shell
```bash
eval "$(sibling --init bash)"
```

Expand All @@ -96,27 +76,17 @@ eval "$(sibling --init bash)"
Get source codes by `git clone` or download from [GitHub](https://github.com/tamada/sibling),
then run `cargo build` to build `sibling`.

```sh
$ git clone https://github.com/tamada/sibling.git # or download from https://github.com/tamada/sibling
$ cd sibling
$ cargo build --release # the binary file is put on target/release/sibling.
```shell
git clone https://github.com/tamada/sibling.git # or download from https://github.com/tamada/sibling
cd sibling
cargo build --release # the binary file is put on target/release/sibling.
```

### :briefcase: Requirements

#### Development

- Rust 1.78 or later
- Dependencies (See `Cargo.toml`)
- clap 4.5.5
- rand 0.8.5
- rust-embed 8.4.0

## :smile: About the project

### :scroll: License

- [WTFPL](https://github.com/tamada/sibling/blob/master/LICNESE)
- [WTFPL](https://github.com/tamada/sibling/blob/master/LICENSE)
- :+1: Commercial use
- :+1: Modification
- :+1: Distribution
Expand Down
Binary file added assets/applescripts/next_folder.applescript
Binary file not shown.
20 changes: 14 additions & 6 deletions assets/completions/bash/sibling
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
_sibling() {
local i cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
cur="$2"
else
cur="${COMP_WORDS[COMP_CWORD]}"
fi
prev="$3"
cmd=""
opts=""

for i in ${COMP_WORDS[@]}
for i in "${COMP_WORDS[@]:0:COMP_CWORD}"
do
case "${cmd},${i}" in
",$1")
Expand All @@ -19,7 +23,7 @@ _sibling() {

case "${cmd}" in
sibling)
opts="-a -l -p -P -s -t -i -h -V --csv --absolute --list --progress --parent --step --init --type --input --generate-completion-files --completion-out-dir --help --version [DIR]..."
opts="-a -l -p -P -s -t -i -h -V --csv --absolute --list --progress --parent --step --log --init --type --input --generate-completion-files --completion-out-dir --help --version [DIR]..."
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
Expand All @@ -33,6 +37,10 @@ _sibling() {
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--log)
COMPREPLY=($(compgen -W "error warn info debug trace" -- "${cur}"))
return 0
;;
--init)
COMPREPLY=($(compgen -f "${cur}"))
return 0
Expand All @@ -54,11 +62,11 @@ _sibling() {
return 0
;;
--completion-out-dir)
COMPREPLY=($(compgen -f "${cur}"))
COMPREPLY=($(compgen -d "${cur}"))
return 0
;;
*)
COMPREPLY=()
COMPREPLY=($(compgen -d "${cur}"))
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
Expand Down
5 changes: 3 additions & 2 deletions assets/completions/elvish/sibling
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ set edit:completion:arg-completer[sibling] = {|@words|
&'sibling'= {
cand -s 'specify the number of times to execute sibling'
cand --step 'specify the number of times to execute sibling'
cand --log 'set the log level'
cand --init 'generate the initialize script for the shell'
cand -t 'specify the nexter type'
cand --type 'specify the nexter type'
Expand All @@ -36,8 +37,8 @@ set edit:completion:arg-completer[sibling] = {|@words|
cand -P 'print parent directory, when no more sibling directories are found'
cand --parent 'print parent directory, when no more sibling directories are found'
cand --generate-completion-files 'Generate completion files'
cand -h 'Print help'
cand --help 'Print help'
cand -h 'Print help (see more with ''--help'')'
cand --help 'Print help (see more with ''--help'')'
cand -V 'Print version'
cand --version 'Print version'
}
Expand Down
14 changes: 12 additions & 2 deletions assets/completions/fish/sibling
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
complete -c sibling -s s -l step -d 'specify the number of times to execute sibling' -r
complete -c sibling -l log -d 'set the log level' -r -f -a "error\t''
warn\t''
info\t''
debug\t''
trace\t''"
complete -c sibling -l init -d 'generate the initialize script for the shell' -r
complete -c sibling -s t -l type -d 'specify the nexter type' -r -f -a "{first\t'',last\t'',previous\t'',next\t'',random\t'',keep\t''}"
complete -c sibling -s t -l type -d 'specify the nexter type' -r -f -a "first\t'The first sibling directory'
last\t'The last sibling directory'
previous\t'The previous sibling directory (step parameter specifies how many to go back)'
next\t'The next sibling directory (step parameter specifies how many to go forward)'
random\t'A random sibling directory (step parameter is ignored)'
keep\t'Keep the current directory (step parameter is ignored)'"
complete -c sibling -s i -l input -d 'directory list from file, if FILE is "-", reads from stdin.' -r
complete -c sibling -l completion-out-dir -d 'Output directory of completion files' -r -F
complete -c sibling -l csv -d 'print the result in the csv format'
Expand All @@ -9,5 +19,5 @@ complete -c sibling -s l -l list -d 'list the sibling directories'
complete -c sibling -s p -l progress -d 'print the progress of traversing directories'
complete -c sibling -s P -l parent -d 'print parent directory, when no more sibling directories are found'
complete -c sibling -l generate-completion-files -d 'Generate completion files'
complete -c sibling -s h -l help -d 'Print help'
complete -c sibling -s h -l help -d 'Print help (see more with \'--help\')'
complete -c sibling -s V -l version -d 'Print version'
5 changes: 3 additions & 2 deletions assets/completions/powershell/sibling
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Register-ArgumentCompleter -Native -CommandName 'sibling' -ScriptBlock {
'sibling' {
[CompletionResult]::new('-s', '-s', [CompletionResultType]::ParameterName, 'specify the number of times to execute sibling')
[CompletionResult]::new('--step', '--step', [CompletionResultType]::ParameterName, 'specify the number of times to execute sibling')
[CompletionResult]::new('--log', '--log', [CompletionResultType]::ParameterName, 'set the log level')
[CompletionResult]::new('--init', '--init', [CompletionResultType]::ParameterName, 'generate the initialize script for the shell')
[CompletionResult]::new('-t', '-t', [CompletionResultType]::ParameterName, 'specify the nexter type')
[CompletionResult]::new('--type', '--type', [CompletionResultType]::ParameterName, 'specify the nexter type')
Expand All @@ -39,8 +40,8 @@ Register-ArgumentCompleter -Native -CommandName 'sibling' -ScriptBlock {
[CompletionResult]::new('-P', '-P ', [CompletionResultType]::ParameterName, 'print parent directory, when no more sibling directories are found')
[CompletionResult]::new('--parent', '--parent', [CompletionResultType]::ParameterName, 'print parent directory, when no more sibling directories are found')
[CompletionResult]::new('--generate-completion-files', '--generate-completion-files', [CompletionResultType]::ParameterName, 'Generate completion files')
[CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
[CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
[CompletionResult]::new('-V', '-V ', [CompletionResultType]::ParameterName, 'Print version')
[CompletionResult]::new('--version', '--version', [CompletionResultType]::ParameterName, 'Print version')
break
Expand Down
19 changes: 15 additions & 4 deletions assets/completions/zsh/_sibling
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,20 @@ _sibling() {
_arguments "${_arguments_options[@]}" : \
'-s+[specify the number of times to execute sibling]:COUNT:_default' \
'--step=[specify the number of times to execute sibling]:COUNT:_default' \
'--log=[set the log level]:LEVEL:(error warn info debug trace)' \
'--init=[generate the initialize script for the shell]:SHELL:_default' \
'-t+[specify the nexter type]:TYPE:(first last previous next random keep)' \
'--type=[specify the nexter type]:TYPE:(first last previous next random keep)' \
'-t+[specify the nexter type]:TYPE:((first\:"The first sibling directory"
last\:"The last sibling directory"
previous\:"The previous sibling directory (step parameter specifies how many to go back)"
next\:"The next sibling directory (step parameter specifies how many to go forward)"
random\:"A random sibling directory (step parameter is ignored)"
keep\:"Keep the current directory (step parameter is ignored)"))' \
'--type=[specify the nexter type]:TYPE:((first\:"The first sibling directory"
last\:"The last sibling directory"
previous\:"The previous sibling directory (step parameter specifies how many to go back)"
next\:"The next sibling directory (step parameter specifies how many to go forward)"
random\:"A random sibling directory (step parameter is ignored)"
keep\:"Keep the current directory (step parameter is ignored)"))' \
'-i+[directory list from file, if FILE is "-", reads from stdin.]:FILE:_default' \
'--input=[directory list from file, if FILE is "-", reads from stdin.]:FILE:_default' \
'--completion-out-dir=[Output directory of completion files]:DIR:_files' \
Expand All @@ -33,8 +44,8 @@ _sibling() {
'-P[print parent directory, when no more sibling directories are found]' \
'--parent[print parent directory, when no more sibling directories are found]' \
'--generate-completion-files[Generate completion files]' \
'-h[Print help]' \
'--help[Print help]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'-V[Print version]' \
'--version[Print version]' \
'*::dirs -- the target directory:_files' \
Expand Down
22 changes: 13 additions & 9 deletions assets/init/init.bash
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@ __change_directory_to_sibling() {
if [[ $# -eq 2 ]]; then
step=$2
fi
next=$(sibling --type $traversing_type --csv --step $step)
result=$(sibling --type $traversing_type --csv --step $step)
sibling_status=$?
result=($(echo $next | tr -s ',' ' '))
if [[ $sibling_status -eq 0 ]] ; then
cd "$(echo ${result[2]} | xargs)"
echo "$PWD (${result[4]}/${result[5]})"
else
echo "Done (${result[4]}/${result[5]})"
cd ..
fi
echo $result | while IFS=, read current next ci ni total
do
# echo "Current: $current, Next: $next, ci: $ci, ni: $ni, total: $total"
if [[ $sibling_status -eq 0 ]] ; then
# strip the first and last double quotes
cd "$(echo $next | sed -e 's/^"//' -e 's/"$//')"
echo "$PWD ($ci/$total)"
else
echo "Done ($ci/$total)"
cd ..
fi
done
Comment on lines +12 to +23

Copilot AI Jan 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cd command inside the while loop runs in a subshell due to the pipe, which means the directory change won't affect the parent shell. This will cause the function to not actually change directories as intended. The solution is to avoid piping into the while loop and instead use process substitution or read the CSV differently.

Copilot uses AI. Check for mistakes.
return $sibling_status
}

Expand Down
7 changes: 5 additions & 2 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
name = "sibling-cli"
readme = "README.md"
description = "get next/previous sibling directory name."
categories = ["command-line-utilities"]
categories = ["command-line-utilities", "filesystem"]
keywords = ["directory-traversal", "sibling-directories", "filesystem", "cli"]
repository.workspace = true
homepage.workspace = true
version.workspace = true
Expand All @@ -12,6 +13,8 @@ edition.workspace = true
[dependencies]
clap = { version = "4.5.23", features = ["derive"] }
clap_complete = "4.5.38"
env_logger = "0.11.8"
log = "0.4.29"
rust-embed = "8.5.0"
sibling = { path = "../lib"}
toml = "0.8.19"
toml = "0.9.8"
Loading
Loading