Crates.io | wcounter |
lib.rs | wcounter |
version | 0.2.4 |
source | src |
created_at | 2020-06-01 06:50:52.591226 |
updated_at | 2021-02-02 15:46:43.788006 |
description | Give the word and count the appearance |
homepage | |
repository | https://github.com/tacogips/wcounter |
max_upload_size | |
id | 248599 |
size | 15,222 |
Give the word and count the appearance.
The first rust project of mine.
cargo install wcounter
Add the words to wcounter, And It show the word list in order of appearances.
> wcounter --dest-file="path/to/file" add some_word
> wcounter --dest-file="path/to/file" add some_word2
> wcounter --dest-file="path/to/file" add some_word3
> wcounter --dest-file="path/to/file" add some_word2
# shows by ascending
> wcounter --dest-file="path/to/file" show
some_word
some_word3
some_word2
# shows by descending
> wcounter --dest-file="path/to/file" show --reverse
some_word2
some_word3
some_word
...
Inspired by the entry
typeset -U chpwd_functions
## save the current directory after cd
CD_HISTORY_FILE=${HOME}/.cd_history_file # cd history filcd history file
function chpwd_record_history() {
echo $PWD | xargs wcounter --dest-file=${CD_HISTORY_FILE} add
}
chpwd_functions=($chpwd_functions chpwd_record_history)
## load the cd history
function fd(){
dest=$(wcounter --dest-file=${CD_HISTORY_FILE} show --reverse | fzf +m --query "$LBUFFER" --prompt="cd > ")
cd $dest
}
To avoid conflict of the output file by written simultaneously by multiple process, wcounter uses cluFlock.The lock file will be created at {dest_file_path}.lock
, and will be reused by another process, so the lock file not deleted automatically.