A comprehensive shell library to streamline your development environment setup on Linux and macOS. This lightweight library provides over 200 functions organized across multiple domains including file management, bookmark systems, configuration management, DevOps automation, language support, security utilities, and AI integration.
- 🔧 Core System Functions: Version management, OS detection, package management
- 📁 File & Directory Management: FZF-powered interactive file operations and archiving
- 🔖 Bookmark System: Quick directory navigation with persistent bookmarks
- ⚙️ Configuration Management: Key-value storage with Base64 encoding and grouping
- 🚀 Project Templates: Support for Go, Node.js, Java, Angular, Python projects
- 🔄 DevOps & CI/CD: GitHub Actions workflow generation
- 📦 Package Management: Homebrew and Oh My Zsh integration
- 🔐 Security & Encryption: AES-256-CBC encryption utilities
- 🧹 String Utilities: Text sanitization and formatting functions
- 💬 Communication & Bots: Telegram Bot API integration
- 🤖 AI & LLM Integration: Gemini agent for translation and AI tasks
- 🌐 Git & Repository Management: GitHub API integration and repository utilities
- 💼 Workspace Management: SSH tunneling and workspace configuration
- 🔨 System Utilities: Process management, port checking, and system analysis
shell/
├── install.sh # Installation script
├── upgrade.sh # Upgrade script
├── uninstall.sh # Uninstallation script
├── Makefile # Build and test automation
└── src/
├── shell.sh # Main entry point
├── lib/ # Core library functions
│ ├── common.sh # System utilities and basic operations
│ ├── bookmark.sh # Bookmark management system
│ ├── key.sh # Configuration key-value management
│ ├── fuzzy.sh # FZF-powered file operations
│ ├── goto.sh # Directory navigation utilities
│ ├── workspace.sh # Workspace and SSH management
│ ├── ssh.sh # SSH key and tunnel management
│ ├── strings.sh # String manipulation utilities
│ ├── homebrew.sh # Homebrew package manager
│ ├── oh_my_zsh.sh # Oh My Zsh integration
│ └── ... # Additional utility modules
├── lang/ # Language-specific support
│ ├── go.sh # Go development utilities
│ ├── python.sh # Python environment management
│ ├── nodejs.sh # Node.js project utilities
│ ├── java.sh # Java project utilities
│ ├── angular.sh # Angular project utilities
│ └── git.sh # Git and GitHub integration
├── devops/ # DevOps and CI/CD utilities
│ └── ci.sh # GitHub Actions workflow generation
├── shield/ # Security and encryption
│ └── crypto.sh # Cryptographic utilities
├── bot/ # Communication integrations
│ └── telegram.sh # Telegram Bot API
└── llm/ # AI and LLM integration
└── agents/
└── gemini.sh # Google Gemini AI agent/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/pnguyen215/shell/master/install.sh)"/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/pnguyen215/shell/master/upgrade.sh)"/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/pnguyen215/shell/master/uninstall.sh)"Access the shell library by opening your terminal and using the commands below. Each command is designed to streamline development environment management on Linux and macOS. Functions are organized by category for easy navigation.
Core functions for system management, version control, and basic operations.
-
shell::version
Displays the current version of the shell library.
Example:shell::version -
shell::upgrade
Upgrades the shell CLI to the latest version available.
Example:shell::upgrade -
shell::uninstall
Removes the shell CLI and its associated files from the system.
Example:shell::uninstall -
shell::base::os
Identifies and returns the current operating system type as a standardized string (e.g., "linux" or "macos").
Example:shell::base::os -
shell::stdout
Outputs text to the terminal with customizable foreground colors usingtputand ANSI escape sequences. Requires a message and a color code (e.g., 46 for cyan).
Example:shell::stdout "Task completed" 46 -
shell::run_cmd
Executes a specified command and logs it to the terminal for tracking purposes.
Example:shell::run_cmd ls -l -
shell::run_cmd_eval
Executes a command usingevaland logs it, useful for dynamic command construction.
Example:shell::run_cmd_eval ls -l -
shell::is_command_available
Checks if a given command exists in the system's PATH, returning a success or failure status.
Example:shell::is_command_available git -
shell::install_package
Installs a package using the appropriate package manager for the OS (e.g.,aptfor Linux,brewfor macOS).
Example:shell::install_package git -
shell::uninstall_package
Uninstalls a package using the OS-appropriate package manager.
Example:shell::uninstall_package git -
shell::list_packages_installed
Lists all packages installed on the system via the native package manager.
Example:shell::list_packages_installed -
shell::create_directory_if_not_exists
Creates a directory (including nested paths) if it does not already exist.
Example:shell::create_directory_if_not_exists /path/to/dir -
shell::create_file_if_not_exists
Creates a file if it does not exist, leaving existing files unchanged.
Example:shell::create_file_if_not_exists config.txt -
shell::unlock_permissions
Assigns full permissions (read, write, execute;chmod 777) to a file or directory.
Example:shell::unlock_permissions ./my_script.sh -
shell::clip_cwd
Copies the current working directory path to the system clipboard.
Example:shell::clip_cwd -
shell::clip_value
Copies a specified text string to the system clipboard.
Example:shell::clip_value "Hello, World!" -
shell::get_temp_dir
Returns the OS-appropriate temporary directory path (e.g.,/tmpon Linux).
Example:TEMP_DIR=$(shell::get_temp_dir) -
shell::logger::command_clip
Prints a command to the terminal without executing it, useful for debugging or logging.
Example:shell::logger::command_clip ls -l -
shell::check_port
Checks if a TCP port is in use (listening). Use-nto suppress output and return a status only.
Examples:shell::check_port 8080shell::check_port 8080 -n
-
shell::kill_port
Terminates all processes listening on a specified TCP port. Use-nfor silent operation.
Examples:shell::kill_port 8080shell::kill_port 8080 -n
-
shell::copy_files
Copies a source file to one or more destination filenames in the current directory.
Example:shell::copy_files source.txt dest1.txt dest2.txt -
shell::move_files
Moves one or more files to a specified destination directory.
Example:shell::move_files /path/to/dest file1.txt file2.txt -
shell::remove_files
Deletes a file or directory recursively with elevated privileges (sudo rm -rf). Use with caution.
Example:shell::remove_files obsolete-dir -
shell::editor
Opens a file from a specified directory in a chosen text editor. Use-nto open in a new instance (if supported).
Examples:shell::editor ~/documentsshell::editor -n ~/documents
-
shell::download_dataset
Downloads a file from a URL and saves it with the specified filename.
Example:shell::download_dataset data.zip https://example.com/data.zip -
shell::unarchive
Extracts a compressed file based on its extension (e.g.,.zip,.tar.gz). Use-nfor no-overwrite mode.
Examples:shell::unarchive archive.zipshell::unarchive -n archive.tar.gz
-
shell::list_high_mem_usage
Displays processes consuming significant memory, sorted by usage.
Example:shell::list_high_mem_usage -
shell::open_link
Opens a URL in the default web browser. Use-nfor silent operation (no output).
Examples:shell::open_link https://example.comshell::open_link -n https://example.com
-
shell::loading_spinner
Displays a console loading spinner for a specified duration (in seconds). Use-nto run indefinitely until stopped.
Examples:shell::loading_spinner 10shell::loading_spinner -n 10
-
shell::measure_time
Measures and reports the execution time of a command in seconds.
Example:shell::measure_time sleep 2 -
shell::async
Runs a command or function asynchronously in the background. Use-nfor no output.
Examples:shell::async my_function arg1 arg2shell::async -n ls
-
shell::fzf_copy
Interactively selects a file to copy and a destination directory usingfzffor fuzzy finding.
Example:shell::fzf_copy -
shell::fzf_move
Interactively selects a file to move and a destination directory usingfzf.
Example:shell::fzf_move -
shell::fzf_remove
Interactively selects a file or directory to remove usingfzf.
Example:shell::fzf_remove -
shell::add_bookmarkAdds a bookmark for the current directory with the specified name. Example:shell::add_bookmark <bookmark name>
-
shell::remove_bookmarkDeletes a bookmark with the specified name from the bookmarks file. Example:shell::remove_bookmark <bookmark_name>
-
shell::remove_bookmark_linuxDeletes a bookmark with the specified name from the bookmarks file. Example:shell::remove_bookmark_linux <bookmark_name>
-
shell::list_bookmarkDisplays a formatted list of all bookmarks. Example:shell::list_bookmark -
shell::go_bookmarkNavigates to the directory associated with the specified bookmark name. Example:shell::go_bookmark <bookmark name>
-
shell::go_backNavigates to the previous working directory. -
shell::goto_versionDisplays the version of the goto script. -
shell::gotoMain function to handle user commands and navigate directories. Example:shell::goto [command]shell::goto_usage
-
shell::install_homebrewInstalls Homebrew using the official installation script. -
shell::removal_homebrewUninstalls Homebrew from the system. -
shell::install_oh_my_zshInstalls Oh My Zsh if it is not already present on the system. Example:shell::install_oh_my_zshshell::install_oh_my_zsh -n
-
shell::removal_oh_my_zshUninstalls Oh My Zsh by removing its directory and restoring the original .zshrc backup if available. Example:shell::removal_oh_my_zshshell::removal_oh_my_zsh -n
-
shell::read_confSources a configuration file, allowing its variables and functions to be loaded into the current shell. Example:shell::read_conf [-n] <filename>shell::read_conf ~/.my-configshell::read_conf -n ~/.my-config
-
shell::add_key_confAdds a configuration entry (key=value) to a constant configuration file. The value is encoded using Base64 before being saved. Example:shell::add_key_conf [-n] <key> <value>shell::add_key_conf my_setting "some secret value"shell::add_key_conf -n my_setting "some secret value"
-
shell::fzf_get_key_confInteractively selects a configuration key from a constant configuration file using fzf, then decodes and displays its corresponding value. -
shell::get_key_conf_valueRetrieves and outputs the decoded value for a given configuration key from the key configuration file. Example:shell::get_key_conf_value my_setting
-
shell::fzf_remove_key_confInteractively selects a configuration key from a constant configuration file using fzf, then removes the corresponding entry from the configuration file. Example:shell::fzf_remove_key_confshell::fzf_remove_key_conf -n
-
shell::fzf_update_key_confInteractively updates the value for a configuration key in a constant configuration file. The new value is encoded using Base64 before updating the file. Example:shell::fzf_update_key_confshell::fzf_update_key_conf -n
-
shell::exist_key_confChecks if a configuration key exists in the key configuration file. Example:shell::exist_key_conf <key>shell::exist_key_conf my_setting
-
shell::fzf_rename_key_confRenames an existing configuration key in the key configuration file. Example:shell::fzf_rename_key_conf [-n]
-
shell::is_protected_key_confChecks if the specified configuration key is protected. Example:shell::is_protected_key_conf <key>
-
shell::fzf_add_group_key_confGroups selected configuration keys under a specified group name. Example:shell::fzf_add_group_key_conf [-n]
-
shell::read_group_key_confReads and displays the configurations for a given group by group name. Example:shell::read_group_key_conf <group_name>shell::read_group_key_conf my_group
-
shell::fzf_remove_group_key_confInteractively selects a group name from the group configuration file using fzf, then removes the corresponding group entry. Example:shell::fzf_remove_group_key_conf [-n]
-
shell::fzf_update_group_key_confInteractively updates an existing group by letting you select new keys for that group. Example:shell::fzf_update_group_key_conf [-n]
-
shell::fzf_rename_group_key_confRenames an existing group in the group configuration file. Example:shell::fzf_rename_group_key_conf [-n]
-
shell::list_group_key_confLists all group names defined in the group configuration file. -
shell::fzf_view_group_key_confInteractively selects a group name from the group configuration file using fzf, then lists all keys belonging to the selected group and uses fzf to choose one key, finally displaying the decoded value for the selected key. -
shell::fzf_clone_group_key_confClones an existing group by creating a new group with the same keys. Example:shell::fzf_clone_group_key_conf [-n]
-
shell::sync_group_key_confSynchronizes group configurations by ensuring that each group's keys exist in the key configuration file. If a key listed in a group does not exist, it is removed from that group. If a group ends up with no valid keys, that group entry is removed. Example:shell::sync_group_key_conf [-n]
-
shell::telegram::sendSends a message via the Telegram Bot API.-
Parameters:
- -n : Optional dry-run flag. If provided, the command is printed using shell::logger::command_clip instead of executed.
- token : The Telegram Bot API token.
- chat_id : The chat identifier where the message should be sent.
- message : The message text to send.
-
shell::telegram::send [-n] <token> <chat_id> <message>
-
-
shell::git::telegram::send_activitySends a historical GitHub-related message via Telegram using stored configuration keys.-
Parameters:
- -n : Optional dry-run flag. If provided, the command is printed using shell::logger::command_clip instead of executed.
- message : The message text to send.
-
shell::git::telegram::send_activity [-n] <message>
-
-
shell::telegram::send_documentSends one or more attachments (files) via Telegram using the Bot API asynchronously.-
Parameters:
- -n : Optional dry-run flag. If provided, the command is printed using shell::logger::command_clip instead of executed.
- token : The Telegram Bot API token.
- chat_id : The chat identifier where the message should be sent.
- description: A text description that is appended to each attachment's caption along with a timestamp.
- filename_X: One or more filenames of the attachments to send.
-
shell::telegram::send_document [-n] <token> <chat_id> <description> [filename_1] [filename_2] [filename_3] ...
-
-
shell::fzf_zip_attachmentZips selected files from a specified folder and outputs the absolute path of the created zip file.-
Parameters:
- -n : Optional dry-run flag. If provided, the command is printed using shell::logger::command_clip instead of executed.
- folder_path : The folder (directory) from which to select files for zipping.
-
shell::fzf_zip_attachment [-n] <folder_path>
-
-
shell::fzf_current_zip_attachmentReuses shell::fzf_zip_attachment to zip selected files from the current directory, then renames the resulting zip file to use the current directory's basename and places it inside the current directory.-
Parameters:
- -n : Optional dry-run flag. If provided, the command is printed using shell::logger::command_clip instead of executed.
-
shell::fzf_current_zip_attachment [-n]
-
-
shell::fzf_send_telegram_attachmentUses fzf to interactively select one or more files from a folder (default: current directory), and sends them as attachments via the Telegram Bot API by reusing shell::telegram::send_document.-
Parameters:
- -n : Optional dry-run flag. If provided, the command is printed using shell::logger::command_clip instead of executed.
- token: The Telegram Bot API token.
- chat_id: The chat identifier where the attachments are sent.
- description: A text description appended to each attachment's caption along with a timestamp.
- folder_path: (Optional) The folder to search for files; defaults to the current directory if not provided.
-
shell::fzf_send_telegram_attachment [-n] <token> <chat_id> <description> [folder_path]
-
Interactive file operations powered by FZF (fuzzy finder) for enhanced user experience.
-
shell::create_directory_if_not_exists
Creates a directory (including nested paths) if it does not already exist.
Example:shell::create_directory_if_not_exists /path/to/dir -
shell::create_file_if_not_exists
Creates a file if it does not exist, leaving existing files unchanged.
Example:shell::create_file_if_not_exists config.txt -
shell::copy_files
Copies a source file to one or more destination filenames in the current directory.
Example:shell::copy_files source.txt dest1.txt dest2.txt -
shell::move_files
Moves one or more files to a specified destination directory.
Example:shell::move_files /path/to/dest file1.txt file2.txt -
shell::remove_files
Deletes a file or directory recursively with elevated privileges (sudo rm -rf). Use with caution.
Example:shell::remove_files obsolete-dir -
shell::unarchive
Extracts a compressed file based on its extension (e.g.,.zip,.tar.gz). Use-nfor no-overwrite mode.
Examples:shell::unarchive archive.zipshell::unarchive -n archive.tar.gz
-
shell::fzf_copy
Interactively selects a file to copy and a destination directory usingfzffor fuzzy finding.
Example:shell::fzf_copy -
shell::fzf_move
Interactively selects a file to move and a destination directory usingfzf.
Example:shell::fzf_move -
shell::fzf_remove
Interactively selects a file or directory to remove usingfzf.
Example:shell::fzf_remove -
shell::unlock_permissions
Assigns full permissions (read, write, execute;chmod 777) to a file or directory.
Example:shell::unlock_permissions ./my_script.sh -
shell::set_permissions
Sets specific permissions on files or directories.
Example:shell::set_permissions 755 ./script.sh -
shell::fzf_set_permissions
Interactively select files and set permissions using FZF.
Example:shell::fzf_set_permissions -
shell::analyze_permissions
Analyzes and displays permissions for files in a directory.
Example:shell::analyze_permissions
Persistent bookmark system for quick directory navigation.
-
shell::add_bookmarkAdds a bookmark for the current directory with the specified name. Example:shell::add_bookmark project1
-
shell::remove_bookmarkDeletes a bookmark with the specified name from the bookmarks file. Example:shell::remove_bookmark project1
-
shell::list_bookmarkDisplays a formatted list of all bookmarks. Example:shell::list_bookmark -
shell::go_bookmarkNavigates to the directory associated with the specified bookmark name. Example:shell::go_bookmark project1
-
shell::fzf_list_bookmarkInteractively browse and navigate to bookmarks using FZF. Example:shell::fzf_list_bookmark -
shell::fzf_remove_bookmarkInteractively select and remove bookmarks using FZF. Example:shell::fzf_remove_bookmark -
shell::rename_bookmarkRenames an existing bookmark. Example:shell::rename_bookmark old_name new_name -
shell::fzf_rename_bookmarkInteractively rename bookmarks using FZF. Example:shell::fzf_rename_bookmark -
shell::gotoMain function to handle user commands and navigate directories. Example:shell::goto [command]- Use
shell::gotofor help
Secure key-value storage system with Base64 encoding and group management.
-
shell::read_confSources a configuration file, allowing its variables and functions to be loaded into the current shell. Example:shell::read_conf ~/.my-configshell::read_conf -n ~/.my-config
-
shell::add_key_confAdds a configuration entry (key=value) to a constant configuration file. The value is encoded using Base64 before being saved. Example:shell::add_key_conf my_setting "some secret value"shell::add_key_conf -n my_setting "some secret value"
-
shell::get_key_conf_valueRetrieves and outputs the decoded value for a given configuration key from the key configuration file. Example:shell::get_key_conf_value my_setting
-
shell::fzf_get_key_confInteractively selects a configuration key from a constant configuration file using fzf, then decodes and displays its corresponding value. Example:shell::fzf_get_key_conf -
shell::fzf_remove_key_confInteractively selects a configuration key from a constant configuration file using fzf, then removes the corresponding entry from the configuration file. Example:shell::fzf_remove_key_conf -
shell::fzf_update_key_confInteractively updates the value for a configuration key in a constant configuration file. Example:shell::fzf_update_key_conf -
shell::exist_key_confChecks if a configuration key exists in the key configuration file. Example:shell::exist_key_conf my_setting -
shell::fzf_rename_key_confRenames an existing configuration key in the key configuration file. Example:shell::fzf_rename_key_conf
Group-based configuration management for organizing related keys.
-
shell::fzf_add_group_key_confGroups selected configuration keys under a specified group name. Example:shell::fzf_add_group_key_conf -
shell::read_group_key_confReads and displays the configurations for a given group by group name. Example:shell::read_group_key_conf my_group -
shell::fzf_remove_group_key_confInteractively selects a group name from the group configuration file using fzf, then removes the corresponding group entry. Example:shell::fzf_remove_group_key_conf -
shell::list_group_key_confLists all group names defined in the group configuration file. Example:shell::list_group_key_conf -
shell::fzf_view_group_key_confInteractively selects a group and displays key values. Example:shell::fzf_view_group_key_conf -
shell::sync_group_key_confSynchronizes group configurations by ensuring that each group's keys exist in the key configuration file. Example:shell::sync_group_key_conf
Utilities for various programming languages and project initialization.
-
shell::go::module::createCreates a new Go application with proper structure. Example:shell::go::module::create myapp -
shell::go::env::set_privateSets up private Go module configuration. Example:shell::go::env::set_private github.com/myorg -
shell::go::env::get_privateRetrieves current private Go module settings. Example:shell::go::env::get_private -
shell::go::env::remove_private_fzfInteractively remove private Go module settings. Example:shell::go::env::remove_private_fzf -
shell::go::gitignore::addAdds Go-specific .gitignore file to the current project. Example:shell::go::gitignore::add
-
shell::python::installInstalls Python using the system package manager. Example:shell::python::install 3.11 -
shell::python::venv::createCreates a new Python virtual environment. Example:shell::python::venv::create myenv -
shell::python::venv::activate_fzfInteractively activate a Python virtual environment. Example:shell::python::venv::activate_fzf -
shell::python::venv::pkg::installInstalls packages in the active Python environment. Example:shell::python::venv::pkg::install requests pandas -
shell::python::venv::pkg::freezeGenerates requirements.txt from current environment. Example:shell::python::venv::pkg::freeze -
shell::python::gitignore::addAdds Python-specific .gitignore file to the current project. Example:shell::python::gitignore::add
shell::nodejs::gitignore::addAdds Node.js-specific .gitignore file to the current project. Example:shell::nodejs::gitignore::add
shell::java::gitignore::addAdds Java-specific .gitignore file to the current project. Example:shell::java::gitignore::add
shell::angular::gitignore::addAdds Angular-specific .gitignore file to the current project. Example:shell::angular::gitignore::add
GitHub Actions workflow generation and DevOps automation.
-
shell::gh::workflow::base::addAdds a base GitHub Actions workflow configuration. Example:shell::gh::workflow::base::add -
shell::gh::workflow::news::addAdds a news/notification GitHub Actions workflow. Example:shell::gh::workflow::news::add -
shell::gh::workflow::bash::add_formatAdds a shell script formatting GitHub Actions workflow. Example:shell::gh::workflow::bash::add_format
System package managers and development tool installation.
-
shell::install_homebrewInstalls Homebrew using the official installation script. Example:shell::install_homebrew -
shell::removal_homebrewUninstalls Homebrew from the system. Example:shell::removal_homebrew
-
shell::install_oh_my_zshInstalls Oh My Zsh if it is not already present on the system. Example:shell::install_oh_my_zsh -
shell::removal_oh_my_zshUninstalls Oh My Zsh by removing its directory and restoring the original .zshrc backup if available. Example:shell::removal_oh_my_zsh
AES-256-CBC encryption utilities for secure data handling.
shell::generate_random_keyGenerates a random encryption key for use with AES-256-CBC. Example:shell::generate_random_key
Text manipulation and sanitization functions.
-
shell::strings::sanitize::upperConverts text to uppercase variable naming convention. Example:shell::strings::sanitize::upper "my variable name" -
shell::strings::sanitize::lowerConverts text to lowercase variable naming convention. Example:shell::strings::sanitize::lower "My Variable Name" -
shell::strings::format::camelConverts text to camelCase format. Example:shell::strings::format::camel "my variable name" -
shell::strings::format::titleCapitalizes the first letter of each word. Example:shell::strings::format::title "hello world" -
shell::strings::sanitize::escapeGeneral text sanitization function. Example:shell::strings::sanitize::escape "text with special chars!"
Telegram Bot API integration for notifications and file sharing.
-
shell::telegram::sendSends a message via the Telegram Bot API. Parameters:- -n : Optional dry-run flag
- token : The Telegram Bot API token
- chat_id : The chat identifier where the message should be sent
- message : The message text to send
Example:
shell::telegram::send <token> <chat_id> "Hello, World!"
-
shell::telegram::send_documentSends one or more attachments (files) via Telegram using the Bot API asynchronously. Example:shell::telegram::send_document <token> <chat_id> "Files" file1.txt file2.txt -
shell::git::telegram::send_activitySends a historical GitHub-related message via Telegram using stored configuration keys. Example:shell::git::telegram::send_activity "Deployment completed"
Google Gemini AI agent integration for translation and AI tasks.
-
shell::make_gemini_requestMakes a request to the Google Gemini API. Example:shell::make_gemini_request "Translate this text" -
shell::eval_gemini_en_viTranslates English text to Vietnamese using Gemini. Example:shell::eval_gemini_en_vi "Hello, how are you?" -
shell::eval_gemini_vi_enTranslates Vietnamese text to English using Gemini. Example:shell::eval_gemini_vi_en "Xin chào, bạn khỏe không?" -
shell::populate_gemini_confSets up Gemini configuration. Example:shell::populate_gemini_conf -
shell::fzf_view_gemini_confInteractively view Gemini configuration using FZF. Example:shell::fzf_view_gemini_conf
GitHub API integration and repository utilities.
-
shell::git::release::version::getRetrieves the latest release information from a GitHub repository. Example:shell::git::release::version::get pnguyen215/shell -
shell::retrieve_gh_repository_infoRetrieves repository information from GitHub. Example:shell::retrieve_gh_repository_info pnguyen215/shell -
shell::retrieve_current_gh_default_branchGets the default branch of the current repository. Example:shell::retrieve_current_gh_default_branch -
shell::retrieve_current_gh_current_branchGets the current branch of the repository. Example:shell::retrieve_current_gh_current_branch
SSH tunneling and workspace configuration management.
-
shell::add_workspaceAdds a new workspace configuration. Example:shell::add_workspace myworkspace -
shell::fzf_view_workspaceInteractively view workspace configurations. Example:shell::fzf_view_workspace -
shell::fzf_manage_workspaceInteractively manage workspace configurations. Example:shell::fzf_manage_workspace -
shell::open_workspace_ssh_tunnelOpens SSH tunnel for a workspace. Example:shell::open_workspace_ssh_tunnel myworkspace -
shell::fzf_open_workspace_ssh_tunnelInteractively open SSH tunnels using FZF. Example:shell::fzf_open_workspace_ssh_tunnel
SSH key and tunnel management utilities.
-
shell::gen_ssh_keyGenerates a new SSH key pair. Example:shell::gen_ssh_key mykey -
shell::fzf_view_ssh_keyInteractively view SSH keys using FZF. Example:shell::fzf_view_ssh_key -
shell::open_ssh_tunnelOpens an SSH tunnel with specified parameters. Example:shell::open_ssh_tunnel user@host:port -
shell::list_ssh_tunnelsLists active SSH tunnels. Example:shell::list_ssh_tunnels -
shell::fzf_kill_ssh_tunnelsInteractively kill SSH tunnels using FZF. Example:shell::fzf_kill_ssh_tunnels
Process management, port checking, and system analysis tools.
-
shell::base::os
Identifies and returns the current operating system type as a standardized string (e.g., "linux" or "macos").
Example:shell::base::os -
shell::stdout
Outputs text to the terminal with customizable foreground colors usingtputand ANSI escape sequences. Requires a message and a color code (e.g., 46 for cyan).
Example:shell::stdout "Task completed" 46 -
shell::run_cmd
Executes a specified command and logs it to the terminal for tracking purposes.
Example:shell::run_cmd ls -l -
shell::run_cmd_eval
Executes a command usingevaland logs it, useful for dynamic command construction.
Example:shell::run_cmd_eval ls -l -
shell::is_command_available
Checks if a given command exists in the system's PATH, returning a success or failure status.
Example:shell::is_command_available git -
shell::install_package
Installs a package using the appropriate package manager for the OS (e.g.,aptfor Linux,brewfor macOS).
Example:shell::install_package git -
shell::uninstall_package
Uninstalls a package using the OS-appropriate package manager.
Example:shell::uninstall_package git -
shell::list_packages_installed
Lists all packages installed on the system via the native package manager.
Example:shell::list_packages_installed -
shell::clip_cwd
Copies the current working directory path to the system clipboard.
Example:shell::clip_cwd -
shell::clip_value
Copies a specified text string to the system clipboard.
Example:shell::clip_value "Hello, World!" -
shell::get_temp_dir
Returns the OS-appropriate temporary directory path (e.g.,/tmpon Linux).
Example:TEMP_DIR=$(shell::get_temp_dir) -
shell::check_port
Checks if a TCP port is in use (listening). Use-nto suppress output and return a status only.
Examples:shell::check_port 8080shell::check_port 8080 -n
-
shell::kill_port
Terminates all processes listening on a specified TCP port. Use-nfor silent operation.
Examples:shell::kill_port 8080shell::kill_port 8080 -n
-
shell::list_high_mem_usage
Displays processes consuming significant memory, sorted by usage.
Example:shell::list_high_mem_usage -
shell::open_link
Opens a URL in the default web browser. Use-nfor silent operation (no output).
Examples:shell::open_link https://example.comshell::open_link -n https://example.com
-
shell::loading_spinner
Displays a console loading spinner for a specified duration (in seconds). Use-nto run indefinitely until stopped.
Examples:shell::loading_spinner 10shell::loading_spinner -n 10
-
shell::measure_time
Measures and reports the execution time of a command in seconds.
Example:shell::measure_time sleep 2 -
shell::async
Runs a command or function asynchronously in the background. Use-nfor no output.
Examples:shell::async my_function arg1 arg2shell::async -n ls
-
shell::editor
Opens a file from a specified directory in a chosen text editor. Use-nto open in a new instance (if supported).
Examples:shell::editor ~/documentsshell::editor -n ~/documents
-
shell::download_dataset
Downloads a file from a URL and saves it with the specified filename.
Example:shell::download_dataset data.zip https://example.com/data.zip -
shell::validate_ip_addrValidates if a string is a valid IP address. Example:shell::validate_ip_addr 192.168.1.1 -
shell::validate_hostnameValidates if a string is a valid hostname. Example:shell::validate_hostname example.com -
shell::get_mime_typeGets the MIME type of a file. Example:shell::get_mime_type document.pdf
# Add configuration keys
shell::add_key_conf database_url "postgresql://user:pass@localhost:5432/mydb"
shell::add_key_conf api_key "your-secret-api-key"
shell::add_key_conf debug_mode "true"
# Group related configurations
shell::fzf_add_group_key_conf # Select keys and group them as "development"
# Retrieve configuration values
DB_URL=$(shell::get_key_conf_value database_url)
API_KEY=$(shell::get_key_conf_value api_key)
# View all configurations in a group
shell::read_group_key_conf development# Navigate to project directories and bookmark them
cd ~/projects/webapp
shell::add_bookmark webapp
cd ~/projects/api-service
shell::add_bookmark api
cd ~/projects/mobile-app
shell::add_bookmark mobile
# Quick navigation
shell::go_bookmark webapp # Direct navigation
shell::fzf_list_bookmark # Interactive selection
shell::list_bookmark # View all bookmarks# Initialize a Go project
shell::go::module::create mygoapp
cd mygoapp
shell::go::gitignore::add
# Set up Python environment
shell::python::venv::create myproject
shell::python::venv::activate_fzf # Activate environment
shell::python::venv::pkg::install requests flask pandas
shell::python::venv::pkg::freeze > requirements.txt# Add GitHub Actions workflows
shell::gh::workflow::base::add # Base CI/CD workflow
shell::gh::workflow::news::add # Notification workflow
shell::gh::workflow::bash::add_format # Shell script formatting
# Send deployment notifications
shell::git::telegram::send_activity "Deployment to production completed successfully"# Generate encryption key
KEY=$(shell::generate_random_key)
# Store sensitive configuration securely
shell::add_key_conf encryption_key "$KEY"
shell::add_key_conf database_password "super-secret-password"
# Keys are automatically Base64 encoded for storage# Set up workspace
shell::add_workspace production
shell::add_workspace_ssh_conf production
# Generate SSH key
shell::gen_ssh_key production-key
# Open SSH tunnel
shell::open_ssh_tunnel user@production-server.com:22
# Interactive workspace management
shell::fzf_manage_workspace
shell::fzf_open_workspace_ssh_tunnel# Set up Gemini configuration
shell::populate_gemini_conf
# Translation services
shell::eval_gemini_en_vi "Hello, how are you today?"
shell::eval_gemini_vi_en "Xin chào, bạn khỏe không?"
# Make custom AI requests
shell::make_gemini_request "Explain the benefits of shell scripting"Most functions support FZF (fuzzy finder) for enhanced interactivity:
shell::fzf_*functions provide interactive selection interfaces- Real-time filtering and search capabilities
- Keyboard navigation with arrow keys and Enter to select
- All configuration values are Base64 encoded for basic obfuscation
- Group-based organization for related settings
- Protected keys system for sensitive data
- Synchronization utilities to maintain data integrity
- Automatic OS detection and appropriate command usage
- macOS-specific functions (e.g.,
shell::opentfor Finder integration) - Linux-specific optimizations
- Package manager abstraction (Homebrew for macOS, apt/yum for Linux)
- Background execution support with
shell::async - Non-blocking operations for time-intensive tasks
- Process management and monitoring utilities
This library follows a modular architecture. Each module is self-contained and focuses on specific functionality:
- Add new functions to appropriate modules in
src/lib/,src/lang/, etc. - Follow the
shell::function_namenaming convention - Include comprehensive documentation and examples
- Test your functions with both Linux and macOS environments
This project is open source and available under the MIT License.