Sunday, September 26, 2021

Search document content in Mac & Linux

 If there's one feature I like most about Mac, it must be the spotlight search 'summoned' via the keyboard shortcut:  command-space.

It searches not only by filenames, but also the content text; not only in text files, but also in RTF, DOC, etc.  It makes folder boundaries disappear, and file names unimportant.  The files indexing is automatically done in background.


In Windows, about 10 years ago,  there was a Google desktop search sidebar tool, but discontinued.


In Linux, we have multiple built-in tools, eg.   updatedb, then locate pattern for file names;  or ascii content by  grep -HERin pattern path;  or  by more search criteria,   'find' command

Ubuntu has its all-in-one search works somewhat similarly.

For other distro's like mxlinux, an option maybe a tool: search monkey.   To install:


    sudo apt update

    sudo apt upgrade

    sudo apt install searchmonkey


For usage, 3 different ways:

(A) bottom-left menu, type search.  prefilled search location   $HOME

(B) terminal command line:


    $ searchmonkey

or 

    $ searchmonkey -d directory -f filename_regex -t text_regex

eg.

    searchmonkey -d /path/to/directory -f txt -t howto


(C) the handy way, configure in thunar preference  i.e. the explorer

file preference > customized action 

select   'find files here'

origin default is catfish

replace it with


        searchmonkey -d %f


then setup keyboard shortcut for this action.

Note that it's real time search, not from pre-processed database.  Therefore, searching in a big folder takes long time.

Labels: , ,

How to Split a Subdirectory to a New Git Repository and Keep the History

 

(modified from: https://ao.ms/how-to-split-a-subdirectory-to-a-new-git-repository-and-keep-the-history/)


Say, original local path is ~/allMyCode

1) origin repo to check out the branch with all the subdirectory history, eg. master


    git checkout master


2) clone a copy


    git clone  ~/allMyCode  ~/newSubset

    cd ~/newSubset


3) in new clone, remove all but the sub directory (below is a one-liner)


    git filter-branch --prune-empty --subdirectory-filter relative/path/to/subdirectory current_branch_name


4) if the new clone is a branch other than 'master', make it the new 'master'


    git branch -m master


5) remove untracked leftovers, such as ignored/hidden files/folders (WARNING: make sure you have backup)


    git clean -fdx


6) fix remote repo URL    // assume new repo empty


    git remote set-url origin  {newRepoURL}


7) push to new repo


    git push -u origin master



Labels: , , ,