maybe
version: 0.5.0
jump to known folder on the command-line
Tested on openSUSE Tumbleweed, Ubuntu and FreeBSD.
Flags
-init
scan $HOME and add folders (six folder-level deep)
-list string
list results for keyword
-datadir string
(default $HOME/.local/share/maybe)
-max-entries int
maximum unique path-entries (default 10000)
-add string
add path to index
-search string
search for keyword
-v verbose
-version
print maybe version
Install
Snap Package
The easiest way to install Maybe is to get the snap package:
sudo snap install maybe
Alternative, compile from source
-
Compile the code with:
git clone https://github.com/thibran/maybe.git cd maybe go build
-
Make the binary system wide accessible:
sudo cp maybe /usr/local/bin
Fish Shell
Create /etc/fish/functions/m.fish and insert:
function m
if [ "$argv[1]" = "" ]
# clear
if [ $PWD != $HOME ]
cd $HOME
end
return $status
end
set d (maybe --search $argv)
if [ $status = 0 ]
# clear
if [ $d != $PWD ]
cd $d
end
else
return 2
end
end
To list results without jumping to the top match create /etc/fish/functions/mm.fish and insert:
function mm
maybe -list $argv
end
To automatically add visited folders to maybe, create/edit /etc/fish/config.fish:
function m_on_pwd --on-variable PWD
maybe -add $PWD
end
Emacs
(defun empty-string-p (str)
(or (null str) (string= "" str)))
(defun maybe (query)
(interactive "sMaybe search-query: ")
(let ((cmd (concat "maybe -search " query)))
(unless (empty-string-p query)
(dired (shell-command-to-string cmd)))))Eshell
(defun maybe-list (query)
(unless (empty-string-p query)
(shell-command-to-string (concat "maybe -list " query))))
(defun eshell/m (&rest q)
"eshell maybe-search function alias"
(if (null q)
(progn (cd "~") ())
(maybe (mapconcat #'symbol-or-string-to-string q " ")
; open dired, don't echo result
(lambda (dir) (cd dir) nil))))
(defun eshell/mm (&rest q)
"eshell maybe-list alias"
(unless (null q)
(maybe-list (mapconcat #'symbol-or-string-to-string q " "))))TODO
- write quiet eshell on-pwd-change elisp handler
- write fish completion, using --show with a sub-command http://fishshell.com/docs/current/index.html#completion-own https://stackoverflow.com/questions/16657803/creating-autocomplete-script-with-sub-commands https://github.com/fish-shell/fish-shell/issues/1217#issuecomment-31441757
