Commit graph

39 commits

Author SHA1 Message Date
Jonathan Hodgson
a9cdb7dfe9 Fix fuzzy creation of new file
FZF exits with a status of 1 if nothing was selected. This is often the
case though if we are creating a new file so I added `|| true` to make
bash continue anyway
2020-12-30 22:21:58 +00:00
Jonathan Hodgson
463100a6a6 Add to readme 2020-12-30 19:43:32 +00:00
Jonathan Hodgson
bfd13ecafc Small change to readme and re-order 2020-12-30 19:38:04 +00:00
Jonathan Hodgson
73894bb252 Make the update and view file changes use all command line positions
Instead of using $1 for file names, $* is used which results in spaces
being allowed without quoting.

This is in line with how the new command works.

As an example, it means the command

```
kb edit this is a test
```

will try and edit a file with the title "this is a test" rather than
"this"
2020-12-30 19:26:15 +00:00
Jonathan Hodgson
05e5cac976 Fix 2 bugs. Deleting file without yaml file and multi-word delete
The first bug output an error if trying to stage the deletion of the
yaml file if the file never existed. The error is now piped to /dev/null
and `|| true` is appended to the line which causes the script to carry
on execution

The second change is when deleting a file, you no longer have to quote
the file name if it is a multi word file. This puts it in line with the
new command
2020-12-30 19:21:31 +00:00
Jonathan Hodgson
9a269628c4 Adds the ability to select a file by any substring of filename or title
Close #18
2020-12-30 19:15:33 +00:00
Jonathan Hodgson
a504c212ef Adds perge-tags option 2020-12-30 17:42:22 +00:00
Jonathan Hodgson
6206986546 Fix handling of yaml files when deleting entries 2020-12-30 17:25:04 +00:00
Jonathan Hodgson
a3bbe9b4a2 Adds the ability to add files that already exist
Work on #16

This was a relatively large amount of work. It introduces assets which
are stored in the assets sub directory and stored in the database with
the asset type in the database.
2020-12-30 16:42:47 +00:00
Jonathan Hodgson
980eef941b Fix yaml retrieval 2020-12-29 09:37:58 +00:00
Jonathan Hodgson
ccbb335ec4 Adds separate functions for yaml header and yaml file 2020-12-29 08:48:25 +00:00
Jonathan Hodgson
51ca57da7f Adds support for yaml files rather than yaml headers 2020-12-29 08:45:14 +00:00
Jonathan Hodgson
d3803d9d33 Merge branch 'master' into add-assets 2020-12-29 08:02:28 +00:00
Jonathan Hodgson
18cd642ce3 Add a requirements section to the readme 2020-12-23 13:14:12 +00:00
Jonathan Hodgson
b532a40f0f Updates list help message 2020-12-23 12:32:36 +00:00
Jonathan Hodgson
3f02dd3ed5 Remove unnecessary chunk of commented code 2020-12-23 12:09:21 +00:00
Jonathan Hodgson
9b77c22011 Allow list command to specify which "type" to list
Close #15
2020-12-23 12:08:09 +00:00
Jonathan Hodgson
4731545df5 Adds git-lfs as a dependency and initialises lfs in the repo 2020-12-23 11:43:18 +00:00
Jonathan Hodgson
dd1c39c79e Correct typo 2020-12-23 10:36:33 +00:00
Jonathan Hodgson
0f2c2a56c4 Adds usage notes to readme 2020-12-23 10:35:31 +00:00
Jonathan Hodgson
d2276f323f Adds recordings 2020-12-23 10:26:05 +00:00
Jonathan Hodgson
3d014913bd Use git lfs for tracking gif files 2020-12-23 10:24:50 +00:00
Jonathan Hodgson
f8260821ea Makes fuzzy the default
If no arguments are passed, it will open the fuzzy search

From here you can search, create and delete
2020-12-22 19:12:37 +00:00
Jonathan Hodgson
c4c3027e07 Adds a setup section to the readme 2020-12-22 17:38:28 +00:00
Jonathan Hodgson
5076c4d9bc Update readme 2020-12-22 17:00:31 +00:00
Jonathan Hodgson
05dc1b93bd Adds makefile
Issue #3

This adds install and uninstall options. It doesn't yet run test due to
issues I'm having with shellcheck and sourced files
2020-12-22 16:37:41 +00:00
Jonathan Hodgson
d56d5ddbfd Fix inconsistency between help message and actions for fzf
ctrl-v should view rather than ctrl-o
2020-12-22 09:38:21 +00:00
Jonathan Hodgson
d70f5398a3 Adds the ability to index folder and re-populate the db
Misc:
The arguments are now sorted alphabetically in the main funciton

close #4
2020-12-22 09:38:04 +00:00
Jonathan Hodgson
5863d5a58f Moves FZF related code into an include 2020-12-22 09:15:35 +00:00
Jonathan Hodgson
34d0a6bf19 Removes some unneeded lines from an early version 2020-12-22 09:07:47 +00:00
Jonathan Hodgson
0ac730ca3c Adds pager option and uses $PAGER environment variable
Due to bat also reading the $PAGER environment variable, I first look to
see if bat is available. If it is, I use that. If it isn't, I use the
$PAGER environment variable. If that's not available, I use cat.

I also added the --editor flag to the help output which had clearly been
missed

Close #12
2020-12-22 08:58:53 +00:00
Jonathan Hodgson
90cef0d7c0 Makes fzf full height and aligns the help header 2020-12-21 20:22:26 +00:00
Jonathan Hodgson
828e21e328 Makes default operation after fzf viewing
Consider adding an option for this in the future
2020-12-21 20:08:02 +00:00
Jonathan Hodgson
f8d04a304a Adds key combinations for fuzzy search
Currently:
* ctrl-n - new file from query
* ctrl-o - view file
* ctrl-e - edit file
* ctrl-d - delete file

close #11
2020-12-21 18:28:13 +00:00
Jonathan Hodgson
caab854c09 Adds update command for externally modified files
This can be used when a file is modified externally. It will update the
sqlite database and potentially run git commands for the change.

If there are 2 files provided, it assumes that the file was moved. The
first filename should be the old file.

The new, edit and delete functions were also re factored slightly to use
this new update function.

Relevant to #4
Close #2
Close #1
2020-12-20 20:04:52 +00:00
Jonathan Hodgson
660c739c18 Moves safeSQL function to utils 2020-12-20 18:28:19 +00:00
Jonathan Hodgson
b84cf93f4a Adds list-tags option
This will list the tags along with the number of number of times it is
used.

An optional --noheader flag can be passed after the command to prevent
the header being printed.

e.g.

```
$ kb list-tags
name              count
----------------  -----
Linux             2
Authentication    1
Pentesting        1
Enumeration       3
Network Protocol  2
```

```
$ kb list-tags --noheader
Linux             2
Authentication    1
Pentesting        1
Enumeration       3
Network Protocol  2
```

This --noheader flag was also added to the list command

Close #10
2020-12-20 18:25:25 +00:00
Jonathan Hodgson
ac031344d3 Splits up file into smaller files
Closes issue #9
2020-12-20 17:07:17 +00:00
Jonathan Hodgson
8ddda7f2b4 This is the initial commit. See description for what currently works
Currently Working:
* creating files
* deleting files
* editing files
* viewing files
* searching by id
* git
    - Initialises repository
    - commits when a file is created or edited (except rename)
    - arbitrary git commands on repo with `kb git ....`
* sql
    - Database is kept up to date when files are added, deleted or
      edited

TODO:
* Recreate database if deleted or freshly cloned
* Add database to gitignore if not in normal location
* Update database if edited without this tool
* Create a git commit if files are deleted or renamed
* makefile for install and test (currently just surecheck)
2020-12-19 15:52:27 +00:00