A python tool connected to your terminal to store important commands and search them in a new and faster way
Project description
fastHistory 2.0 - speed up your terminal!
A python tool connected to your terminal to store important commands, search them in a fast way and automatically paste them into your terminal
Intro
Why you need it?
How often do you need to reuse a command but you cannot remember it (or all the needed options/flags)?
# example of a common but not so 'easy-to-remember' bash command from my bash history
$ tar -xvzf file.tar.gz
How many times do you search the same commands on Google, over and over?
42 times.. yes.. based on my experience the answer is 42
And how many times have you told yourself to store this super useful command but you didn't?
I saved them all ..totally, with a good and detailed explanation for each command
if you know what I am talking about, fastHistory is the tool you are looking for!
Usage sample
fastHistory can save your commands directly from your terminal, all you need is a #
$ tar -xvzf file.tar.gz #
/\
\-- fastHistory will store 'tar -xvzf file.tar.gz' in its internal database
You can specify one or more tags
$ tar -xvzf file.tar.gz #untar #extract #archive
or a description
$ tar -xvzf file.tar.gz #@extract compressed files from archive
or both
$ tar -xvf archive.tar.gz #untar @extract compressed files from archive
To search the saved commands, all you need is f and the selected command wiil be automatically pasted into your terminal!
$ f
For each command you can get a quick summary from the man page
Warning: this feature currently does not cover the syntax of all commands
And easily edit the tag and description fields
Furthermore, you can easily export/import all data to make backups or to share your commands with a different machine
$ f --export
$ f --import fastHistory_2020-03-02.db
Supported OSs
fastHistory can work in any OS with python3
and a bash
terminal
zsh
is also supported!
List of tested OSs:
OS | OS Version | Shell | Python versions | fastHistory version | Test mode | Result | Comment |
---|---|---|---|---|---|---|---|
Ubuntu | 16.04 | bash | 3.6, 3.7, 3.8 | latest | unittest | ||
Ubuntu | 18.04 | bash | 3.6, 3.7, 3.8 | latest | unittest | ||
macOS | 10.15 | bash | 3.6, 3.7, 3.8 | latest | unittest | python3 needs to be installed | |
Fedora | 29 | bash | 3.5 | 2.0.0 | manual | pip3 requires the --user flag |
|
Debian | 9 | bash | 3.5 | 2.0.0 | manual | ||
Debian | 10 | zsh* | 3.7 | 2.0.0 | manual | *syntax limitation | |
Windows* | 10 (1809) | bash | 3.6 | 2.0.0 | manual | *using the Ubuntu terminal for Windows |
How to install
Requirements
python3
python3-pip
(not needed for offline installation)
Install with pip3
pip3 install fasthistory
$HOME/.local/bin/f
- close and reopen your terminal
Note: be sure to not use pip
(python2) nor sudo
(install it only for the current user)
Install in offline mode
- download the latest release with this easy-to-type link or manually download it
wget mkcn.me/f
- (if needed) move it to the remote/offline machine
- unzip it
tar -xvzf f
- run the installer with the target user
cd fastHistory-X.X
./installer.sh
- close and reopen your terminal
Note: all the downloaded files can be deleted after the installation is completed
How to update
Fast generic way (available from 2.1.1)
f --update
- close and reopen your terminal
Update pip3 installation (2.x.x)
pip3 install -U --no-cache-dir fasthistory
f
- close and reopen your terminal
Update offline mode
- same steps as installation
Update old git installations (< 2.0.0)
git pull
./installer.sh
- close and reopen your terminal
f --import <old_fastHistory_folder>/data/*.db
(if not automatically imported)
How to uninstall
- download the installer script (already available in the offline mode)
wget https://raw.githubusercontent.com/mkcn/fastHistory/master/installer.sh
- make it executable and run it with the uninstall flag
chmod +x installer.sh
./installer.sh -u
Note: pip3 install fasthistory
is not sufficient to uninstall fastHistory
Commands and syntax
Simple adding
<command_to_save> #[<tag> [#<tag> ...]][@<description>]
Adding without execution
f --add <command> #[<tag> [#<tag> ...]][@<description>]
or
# <command_to_save> #[<tag> [#<tag> ...]][@<description>]
Note: the latter is not available with zsh
Simple search
f [<filter>]
OR search: match any row where at least one of the following conditions is true:
- the filter words are contained in the command
- the filter words are contained in the tags list
- the filter words are contained in the description
Advanced search
f [<filter>] [#<tag_filter> ...] [@<description_filter>]
AND search: match any rows where all the following conditions are true:
- the filter words are contained in the command OR tags OR description
- the tag_filter words are contained in the tag list
- the description_filter words contained in the description
Export database
f --export [<output_name>]
- the output is the file name of the output database (this parameter is optional)
Import external database
f --import <input_name>
- the input_name is the file name of the input database (e.g. fastHistory_2019-03-23.db)
Change fastHistory configuration
f --config
Force a fastHistory setup to fix possible issues
f --setup
this may be needed if you install zsh after fastHistory
Check fastHistory version
f --version
Update fastHistory
f --update
Show fastHistory help
f --help
Troubleshooting
To fix common issues you can:
- run
f --setup
to automatically check and fix your environment - explicitly call
$HOME/.local/bin/f
instead off
- restart your terminal to reload the bash hook
In case of persistent issues please report them together with the following info:
- OS version
- fastHistory version (
f --version
)
fastHistory structure
user data folder
$HOME/.local/share/fastHistory
$HOME/.local/share/fastHistory/fh_v1.db
(database file)
$HOME/.local/share/fastHistory/fh.log
(log file)
code folder (pip3 mode)
$HOME/.local/lib/pythonX.Y/site-packages/fastHistory/
code folder (offline mode)
$HOME/.fastHistory/
bash (zsh) hook in $HOME/.bashrc
($HOME/.zsh
)
...
source "/home/USER/.local/lib/pythonX.Y/site-packages/fastHistory/bash/f.sh"
License
The license for this is the same as that used by GNU bash, GNU GPL v3+.
Copyright
The following external projects have been used as part of fastHistory:
- https://github.com/rcaloras/bash-preexec
- goal: this bash script is used to hook the commands from the terminal
- code section:
bash-preexec.sh
- changes: no change
- https://github.com/idank/bashlex
- goal: this Python module is used to parse bash commands in order to show info from the man page
- code section:
fastHistory/parser/bashlex/
- changes: no change
- https://github.com/wong2/pick
- goal: this Python module has been used to select the option from the menu
- code section:
fastHistory/pick
- changes: all code has been restructured and adapted with a different UI
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for fastHistory-2.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68bfa5e5a8e933820fb904aa9277aadacc3ae749cc360a6a89f66e6a20c83453 |
|
MD5 | b249ac619a7cc10dd5e722155314a6ec |
|
BLAKE2b-256 | 36585e3c95ec84d5c609ef05ac43c3ce5954fea1d18518ac0a4c9bd95c6a624e |