Discover how a properly formatted workspace can help you unleash your creative potential and bring your ideas to life with optimized configurations and scripts. Streamline your workflow, reduce errors, and create with ease by trying them out today.
The .bashrc
files in this project improve your experience and productivity when working in the BASH shell.
Notable features include a visually appealing divider displaying the time and date stamp between prompts, which enhances the shell's appearance and aids in debugging:
PROMPT_COMMAND='separator'
# Prompt command to print a graphical divider with time and date stamp between shell prompts.
function separator() {
local datestring=$(date +"%Y%m%d, %A")
local timestring=$(date +"%H:%M:%S")
local separator_length=$(tput cols)
local date_length=${#datestring}
local time_length=${#timestring}
local space_length=$((separator_length - date_length - time_length - 8))
if (( space_length < 0 )); then
space_length=0
fi
# Calculate the actual line length excluding the borders
local line_content_length=$((date_length + space_length + time_length + 4)) # 4 for " β "
# Create the top and bottom lines based on content length
local line_top="β$(printf "%-$((separator_length - 2))s" "" | tr ' ' ' ')β"
local line_bottom="β$(printf "%-$((separator_length - 2))s" "" | tr ' ' ' ')β"
# Construct the middle line
local line_middle="β $(printf " %s %${space_length}s %s " "$datestring" "" "$timestring") β"
# Print the lines with colors
printf "\e[1;34m%s\e[0m\n" "$line_top"
printf "\e[1;37m%s\e[0m\n" "$line_middle"
printf "\e[1;34m%s\e[0m\n" "$line_bottom"
}
β β
β 20230925, Monday 153648 β
β β
The pictured .conkyrc file can be found at https://github.com/apple-fritter/.conkyrc
.
This separator
function creates a visually appealing separator line in a terminal that displays the current date and time, formatted in a specific way. Hereβs a breakdown of how it works:
-
Date and Time Retrieval:
- It fetches the current date in the format
YYYYMMDD, DayOfWeek
and the current time inHH:MM:SS
format.
- It fetches the current date in the format
-
Terminal Width Calculation:
- It determines the width of the terminal using
tput cols
to create a dynamic separator that fits the screen.
- It determines the width of the terminal using
-
Space Calculation:
- It calculates the space needed between the date and time based on the terminal width, accounting for the lengths of the date and time strings, as well as some extra characters for borders and padding.
-
Handling Short Widths:
- If the calculated space is negative (meaning thereβs not enough room), it sets the space to zero to avoid errors.
-
Line Construction:
- It constructs the top and bottom borders using
β
andβ
, filling the space in between with spaces. - The middle line combines the date and time with appropriate spacing and is framed by vertical bars (
β
).
- It constructs the top and bottom borders using
-
Color Formatting:
- The top and bottom lines are printed in blue, and the middle line (which contains the date and time) is printed in white, using ANSI escape codes for color.
-
Output:
- Finally, it prints the three lines to create a boxed effect around the current date and time.
This function provides a nice visual separator for output in a terminal, making it easy to read the current date and time at a glance.
PS1
and PS2
have been defined, enhancing the prompt's appearance.
PS1='\n\u@\h\n[\w]\n'
PS2='\n βββ '
PS1='\n\u@\h\n[\w]\n'
sets the prompt to display the username , hostname, and current working directory, with a newline to form the prompt:
GitHubFAN23@macbookpro
[~/Downloads]
Prompt text goes here_
PS2='\n βββ '
sets the secondary prompt to show a pattern of block characters. This prompt level provides visual indication that more input is expected.
These files also comprise various settings and aliases that streamline frequently used commands, making them more efficient while the history command and history ignoring commands' format have been tailored to enhance productivity, and they includes aliases for referencing system management shell scripts also provided in this repository.
export TIMEFORMAT=$'\nreal %3R\tuser %3U\tsys %3S\tpcpu %P\n'
This alias includes the status=progress
option, which provides real-time information on the transfer speed, amount of data transferred, and estimated time remaining.
alias dd='dd status=progress'
alias du='du -kh'
alias df='df -kTh'
alias ls='ls -aclX --color'
alias alert='notify-send --urgency=low \
-i "$([ $? = 0 ] && echo terminal || echo error)" \
"$(history | tail -n1 | sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'' )"'
alias wget='wget -c --user-agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"'
alias wgetmirror='wget --mirror \
--convert-links \
--adjust-extension \
--page-requisites \
--no-parent \
-c \
-w 2.2 \
-e robots=off \
--no-check-certificate \
--user-agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"'
Executes a sequence of cleanup tasks to optimize system performance. It scans for all schema files that are not utilized by any installed applications and removes them to free up space.
THE SCHEMA CLEANER HAS BEEN DISABLED until it is reliable.
ββ Start Script
β
===============[BEGIN BROKEN SECTION]
ββ Check if the schema directory exists
β ββ Directory doesn't exist
β β ββ Display "Directory <schema_dir> not found." and exit
β ββ Continue to next step
β
ββ Find unused schema files
β ββ Find all schema files in <schema_dir> that are not referenced by installed applications, utilizing gsettings
β ββ Store list of unused schema files in UNUSED_SCHEMAS
β
ββ Remove unused schema files
β ββ Loop for each schema in UNUSED_SCHEMAS
β β ββ Remove the schema file
β β ββ Display "Removed <schema_file>"
β ββ Compile the remaining schema files
β
ββ Compile schemas
β ββ Compile the remaining schema files in <schema_dir> using glib-compile-schemas command
β ββ Binary cache files for the schemas are generated
=================[END BROKEN SECTION]
ββ Clean up
β ββ bash history
β ββ backup files
β ββ DS_Store files
β ββ Thumbs.db files
β ββ tmp files
β ββ Java cache
β ββ SQLite3 history
β ββ system cache
β ββ rotated logs
β ββ trash
β ββ thumbnail cache
β ββ X11 debug logs
β
ββ Remove packages that are no longer needed
ββ Clear the local package cache
ββ End Script
Automates the process of updating all installed software packages on your system. By running the script from a root prompt, it will automatically search for and install any available updates. This saves time and effort while also keeping your system secure and up-to-date.
ββ Start Script
β
ββ Run apt-get update command
β ββ Automatically answer "yes" to any prompts
β
ββ Run apt-get dist-upgrade command
β ββ Automatically answer "yes" to any prompts
β
ββ End Script
Optimizes system performance by rebuilding the Mozilla Firefox configuration from scratch using a backup skeleton, if available. The script also cleans up various files and directories that tend to accumulate over time and occupy valuable storage space.
ββ Start Script
β
ββ Set working directory to the user's home
β
ββ Home Directory Cleanup
β ββ Remove ~/.cache/ and ~/.android/
β ββ Remove specific files: .xsession-errors*, .wget-hsts, .bash_history, .sudo_as_admin_successful
β
ββ Rebuild Browser Configuration
β ββ Remove browser config directories: ~/.config/BraveSoftware, ~/.config/chromium, ~/.mozilla/
β ββ Rebuild browser config from skeleton file (browser-skel.7z)
β
ββ Clean Up Backup Files
β ββ Delete files with .bak extension
β
ββ Clean Up DS_Store Files
β ββ Delete .DS_Store files
β
ββ Clean Up Thumbs.db Files
β ββ Delete Thumbs.db files
β
ββ Clean Up tmp Files
β ββ Delete files with .tmp extension
β
ββ Remove Editor Cruft
β ββ Remove editor config directories: ~/.config/geany/, ~/.config/Code/, ~/.config/featherpad/, ~/.vscode
β
ββ Clean Up Desktop Entry Files
β ββ Delete .desktop files in ~/.local/share/applications/
β
ββ Clean Up Trash
ββ Delete contents of ~/.local/share/Trash/
This script retrieves a list of installed packages on a Debian-based system and saves the package names along with their versions to a tab separated text file, located in the user's Documents directory ~/Documents
Sorts a text file alphabetically and eliminates duplicated lines, saving time and effort while ensuring data accuracy and integrity.
ββ Start Script
β
ββ Sort the contents of file <input_file>
β ββ Store the sorted output in a temporary file <input_file>.tmp
β
ββ Remove duplicate lines from the sorted output
β ββ Store the unique lines in the temporary file <input_file>.tmp
β
ββ Rename the temporary file <input_file>.tmp to <input_file>
β
ββ End Script
This script is a bash shell script designed to convert text files from DOS/Windows
line endings CRLF - Carriage Return Line Feed
to Unix
line endings LF - Line Feed
. When you run this script with a folder path as an argument or without any argument, it will convert all the text files in that folder and its subfolders from DOS/Windows line endings to Unix line endings using the dos2unix command. This is useful when you have files that were created or edited on Windows systems and need to be used on Unix-based systems.
The run_dos2unix_recursive
function is defined to handle the recursive conversion of files in subfolders. It takes one argument, which is the folder path to be processed.
- It loops over all files and folders within the provided folder path using the for loop.
- If the current item in the loop is a subfolder (directory), the function calls itself
run_dos2unix_recursive
recursively to process files within that subfolder. - If the current item is a regular file, it uses the
dos2unix
command to convert the file's line endings from DOS/Windows format to Unix format.
The main
function is defined to handle the execution of the script.
- It checks if any command-line arguments are provided using
$# -eq 0
. If no arguments are provided, it sets the folder_path variable to the current working directory using$(pwd)
. If an argument is provided, it uses that as thefolder_path
. Finally, themain
function is called with the provided command-line argumentsmain "$@"
.
ββ Start Script
β
ββ Check if command-line arguments are provided
β ββ No arguments provided:
β β β
β β ββ Set folder_path to the current working directory ($(pwd))
β β
β ββ Arguments provided
β ββ Set folder_path to the provided argument
β
ββ Call the run_dos2unix_recursive() function with folder_path
β
ββ End Script
Quickly fills a target file with a specified input pattern, making it useful for generating large amounts of sample data for testing or demonstration purposes.
ββ Start Script
β
ββ Define input_file and output_file variables from command line arguments
β ββ Assign the value of the first command line argument to input_file
β ββ Assign the value of the second command line argument to output_file
β
ββ Check if either input_file or output_file is empty
β ββ If either file is empty
β β ββ Prompt user for input file path
β β ββ Prompt user for output file path
β ββ If both input_file and output_file are provided
β ββ Check if the number of arguments is greater than 2
β ββ Display an error message to stderr
β ββ Exit the script with status code 1
β
ββ Use a while loop to continuously append input_file contents to output_file
β ββ Append the contents of input_file to output_file
β
ββ End Script
The while loop continuously appends the contents of the input file to the output file indefinitely, which may result in an infinite loop. You may want to consider adding a condition or an exit condition within the loop to ensure it doesn't run indefinitely.
This software is provided "as is" and without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.
The authors do not endorse or support any harmful or malicious activities that may be carried out with the software. It is the user's responsibility to ensure that their use of the software complies with all applicable laws and regulations.
These files released under the MIT License.