Skip to content

πŸŽ‰πŸ•ΊπŸ’ƒπŸŽŠ Keep the party alive with these Bash configurations and scripts. An optimized environment for effortless workflow and versioning.

License

Notifications You must be signed in to change notification settings

apple-fritter/celebration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸŽ‰πŸ•ΊπŸ’ƒπŸŽŠ celebration

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.

Previously, aliases were rolled into the .bashrc file. As of the 16 September commits, all aliases have been moved over to a ".bash_aliases" file, as appropriate per userlevel.


.bashrc Files

The .bashrc files in this project improve your experience and productivity when working in the BASH shell.


Features

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:

Source

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=80
    local date_length=${#datestring}
    local time_length=${#timestring}
    local space_length=$((separator_length - date_length - time_length - 8))

    local line_top="β”Œ$(printf "%78s" | tr ' ' ' ')┐"
    local line_middle="β”‚ $(printf " %s %${space_length}s %s " "$datestring" "" "$timestring") β”‚"
    local line_bottom="β””$(printf "%78s" | tr ' ' ' ')β”˜"

    printf "%s\n"
    printf "%s\n" "$line_top"
    printf "%s\n" "$line_middle"
    printf "%s\n" "$line_bottom"
}

Example Output

β”Œ                                                                              ┐
β”‚  20230925, Monday                                                    153648  β”‚
β””                                                                              β”˜

Screenshot

Screenshot_2024-01-28_18-21-29
The pictured .conkyrc file can be found at https://github.com/apple-fritter/.conkyrc.

Separator Explained

The separator() function in the provided code generates a graphical divider with a time and date stamp between shell prompts.

  • datestring: This variable stores the formatted current date and day of the week, using the format %Y%m%d, %A. For example, it might be "20230615, Thursday".

  • timestring: This variable stores the formatted current time, using the format %H%M%S. For example, it might be "132900" for 1:29 PM.

  • separator_length: This variable represents the desired length of the separator line. In the provided code, it is set to 80 characters, which is often the default width of a terminal window. You can adjust this value to fit your preferred design.

  • date_length: This variable calculates the length of the datestring using ${#datestring}. It represents the number of characters in the combined date and day of the week.

  • time_length: This variable calculates the length of the timestring using ${#timestring}. It represents the number of characters in the time.

  • space_length: This variable calculates the number of spaces needed to fill the remaining space on the line. It is determined by subtracting the date_length, time_length, and 4 (for the spaces and vertical bars) from the separator_length.

  • line_top: This variable constructs the top line of the separator, consisting of an upper left corner character, a line of spaces ( ) with a length equal to space_length, and an upper right corner character.

  • line_middle: This variable constructs the middle line of the separator, containing a vertical bar (|), a space, the datestring, a dynamic number of spaces to align the timestring, the timestring, a space, and another vertical bar.

  • line_bottom: This variable constructs the bottom line of the separator, similar to line_top but with a lower left corner character and a lower right corner character.

The printf statements are used to print each line of the separator.

Make sure to adjust the separator_length to your desired width, and feel free to modify the formatting to match your preferences.


Prompt levels

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.

Establish the time format for long-running commands
export TIMEFORMAT=$'\nreal %3R\tuser %3U\tsys %3S\tpcpu %P\n'
Progress bar for dd!

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'
Provide aliases for disk usage and space
alias du='du -kh'
alias df='df -kTh'
Show files with color and long format
alias ls='ls -aclX --color'
Create an alias to notify users when a long-running command completes
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$//'\'')"'
Specify default wget arguments to appear as a web browser request, supporting download resumes
alias wget='wget -c --user-agent="Mozilla/5.0 (X11; Linux x86_64; rv:122.0) Gecko/20100101 Firefox/122.0"'

Scripts:

Superuser scripts:

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

Regular User Scripts:

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/

Common Scripts

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 the folder_path. Finally, the main function is called with the provided command-line arguments main "$@".
β”Œβ”€ 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.


License

These files released under the MIT License.

About

πŸŽ‰πŸ•ΊπŸ’ƒπŸŽŠ Keep the party alive with these Bash configurations and scripts. An optimized environment for effortless workflow and versioning.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Languages