terminal_tracker package¶
Submodules¶
terminal_tracker.export module¶
- class terminal_tracker.export.Export(file, timeframe, shell)[source]¶
Bases:
objectThis class helps in exporting the history file in a better usable format
- timeframe¶
whether time values are present in the history file
- Type:
bool
- shell¶
“zsh” or “bash”
- Type:
str
- df¶
- Columns:
Command(str), Main Command (str), Arguments (str), Tags (str)
- Optional Columns:
Time (str), Pretty Time (datetime.datetime)
- Type:
pandas.DataFrame
- time¶
processed for efficient searching of day
- Type:
- html(filename)[source]¶
Converts dataframe to html file of given name, adds the extension “.html” if not present in the filename
- pick(category, value)[source]¶
Sorts the commands in the dataframe by a specified category and value, and stores the sorted dataframe in the same “df” attribute. This method should be used before exporting the dataframe.
- Parameters:
category (str) – The category to sort by. Must be one of “tag” or “time”.
value (str) – The value to filter by. If category is “tag”, this should be a tag name. If category is “time”, this should be a date string in the format “YYYY-MM-DD”.
- Raises:
ValueError – If category is not one of “tag” or “time”.
Exception – If category is “time”, but the file doesnot have time values
- sort_by(way)[source]¶
Sorts the commands in the dataframe using various methods and stores the sorted commands in the same “df” attribute. This method should be used before exporting the dataframe.
- Parameters:
way (str) – The method to use for sorting. Must be one of the following:, “Start Command”: Sort by the start command of each command. “Full Command”: Sort by the full command. “Start Frequency”: Keep only unique full commands with their frequency. “Full Frequency”: Keep only unique start commands with their frequency. “Collate Main”: Group the commands by their start command.
- Raises:
ValueError – If way is not one of “Start Command”, “Full Command”, “Start Frequency”, “Full Frequency”, or “Collate Main”.
terminal_tracker.frequency module¶
- class terminal_tracker.frequency.FrequencyFile(file, timeframe=False, shell='zsh')[source]¶
Bases:
objectThis class helps to calculate the frequencies of the commands
- file¶
path to the history file
- Type:
str
- timeframe¶
whether time values are present in the history file
- Type:
bool
- shell¶
“zsh” or “bash”
- Type:
str
- full_command_freq¶
Frequency of each “full” command
- Type:
dic
- start_command_freq¶
Frequency of each “start” command
- Type:
dic
- full_command_freq¶
Frequency of each “full” command in order of decreasing frequency
- Type:
list
- start_command_freq¶
Frequency of each “start” command in order of decreasing frequency
- Type:
dic
Todo
Only works with files without timeframe and tags
- calc_full_command_freq()[source]¶
Calculates the frequency of each “full” command
- Returns:
Frequency of each “full” command
- Return type:
dic
- calc_start_command_freq()[source]¶
Calculates the frequency of each “start” command
- Returns:
Frequency of each “start” command
- Return type:
dic
- find_most_frequent()[source]¶
Finds the most frequent “full” command
- Returns:
most frequent “full” command
- Return type:
str
- find_most_frequent_start()[source]¶
Finds the most frequent “start” command
- Returns:
most frequent “start” command
- Return type:
str
- find_top_full(t=10)[source]¶
Finds the top “t” most frequent “full” command
- Parameters:
t (int) – Number of commands
- Returns:
top “t” most frequent “full” command
- Return type:
list
- find_top_start(t=10)[source]¶
Finds the top “t” most frequent “start” command
- Parameters:
t (int) – Number of commands
- Returns:
top “t” most frequent “start” command
- Return type:
list
terminal_tracker.preprocess module¶
- class terminal_tracker.preprocess.Preprocessing(file, timeframe=False, shell='zsh')[source]¶
Bases:
objectThis class helps in preprocessing the history files
- file¶
path to the history file
- Type:
str
- timeframe¶
whether time values are present in the history file
- Type:
bool
- shell¶
“zsh” or “bash”
- Type:
str
- df¶
- Columns:
Command(str), Main Command (str), Arguments (str), Tags (str)
- Optional Columns:
Time (str), Pretty Time (datetime.datetime)
- Type:
pandas.DataFrame
terminal_tracker.searching module¶
- class terminal_tracker.searching.SearchFile(file)[source]¶
Bases:
objectThis is a simple search class .. attribute:: file
path to the history file
- type:
str
Todo
Move to using the Preprocessing class
- find(a)[source]¶
Finds all commands containing the word
- Parameters:
a (str) – word
- Returns:
commands containing the word
- Return type:
list
- latest(a)[source]¶
Finds the latest command containing the word
- Parameters:
a (str) – word
- Returns:
the latest command containing the word
- Return type:
str
terminal_tracker.tag module¶
- class terminal_tracker.tag.Tags(file, timeframe, shell)[source]¶
Bases:
objectThis class helps to search commands with certain tags
- prep¶
Preprocessing the file using the Preprocessing class
- Type:
- df¶
Preprocessed dataframe Columns:
Command(str), Main Command (str), Arguments (str), Tags (str)
- Optional Columns:
Time (str), Pretty Time (datetime.datetime)
- Type:
pandas.DataFrame
terminal_tracker.timeanalysis module¶
- class terminal_tracker.timeanalysis.TimeAnalysis(file, shell)[source]¶
Bases:
objectThis class helps to search commands with certain tags
- prep¶
Preprocessing the file using the Preprocessing class
- Type:
- df¶
Preprocessed dataframe Columns:
Command(str), Main Command (str), Arguments (str), Tags (str), Time (str), Pretty Time (datetime.datetime)
- Type:
pandas.DataFrame
Todo
reject files with no timeframe