Skip to content

Startup configuration file for Windows Terminal with custom aliases and functions for automation and enhanced productivity.

License

Notifications You must be signed in to change notification settings

swarajkumarsingh/windows-terminal-bash-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Windows Terminal Bash Configuration

For all Windows Terminal lovers, this repository contains a custom .bashrc script tailored for Windows Terminal users. Which runs when the terminal gets initiated It includes helpful functions, aliases, and configurations to streamline development workflows, especially for Docker, AWS, and general command-line usage.


Features

1. AWS Account Query Function

Easily retrieve the current AWS account ID using the aws sts get-caller-identity command.

  • Alias: awsuser

2. Docker Status Checker

Checks if Docker is running; if not, it attempts to start Docker Desktop. Provides real-time feedback until Docker is ready.

  • Aliases: sdocker, start_docker, startDocker, startdocker

3. Project Navigation

Quickly navigate to the D://projects directory with cdd.

4. Common Command Shortcuts

  • run or run.sh: Run your run.sh script.
  • reload: Reload the .bashrc file.
  • ll: List directory contents in detailed format.
  • c, cls: Clear the terminal.
  • .., ...: Navigate up one or two directory levels.

Installation

  1. Clone the Repository

    git clone https://github.com/<your-username>/windows-terminal-bash-config.git
    cd windows-terminal-bash-config
  2. Copy the .bashrc Script

    cp .bashrc ~/
  3. Reload .bashrc Open your terminal and reload the configuration:

    source ~/.bashrc

.bashrc Script Overview

Below is the content of the .bashrc file for your reference:

# Get current AWS account
aws_current_account() {
  aws sts get-caller-identity --query 'Account' --output text
}

# Function to say docker is running
check_docker() {
if docker info > /dev/null 2>&1; then
        echo "Docker is ALIVE baby :)"
else
        echo "Sorry Docker is DEAD :("
fi
}

# Function to check if Docker is running
check_and_start_docker() {
  if ! docker info > /dev/null 2>&1; then
    echo "Docker is not running. Starting Docker Desktop..."
    # Start Docker Desktop (default location for 64-bit systems)
    "/c/Program Files/Docker/Docker/Docker Desktop.exe" &
    # Wait until Docker is ready
    while ! docker info > /dev/null 2>&1; do
      echo "Waiting for Docker to start..."
      sleep 5
    done
    echo "Docker is now running!"
  else
    echo "Docker is already running."
  fi
}

# Docker aliases
alias hidocker='check_docker'
alias hellodocker='check_docker'
alias isdocker='check_docker'
alias yodocker='check_docker'
alias sdocker='check_and_start_docker'
alias dockerStart='check_and_start_docker'
alias docker_start='check_and_start_docker'
alias dockerstart='check_and_start_docker'
alias start_docker='check_and_start_docker'
alias startDocker='check_and_start_docker'
alias startdocker='check_and_start_docker'

# Stop Docker aliases
alias stopdocker='wsl --shutdown'
alias stopDocker='wsl --shutdown'
alias stop_docker='wsl --shutdown'

# Navigation aliases
alias cdd='cd D://projects'

# Script runner aliases
alias run='./run.sh'
alias run.sh='./run.sh'

# Reload .bashrc
alias reload='source ~/.bashrc'

# Utility aliases
alias ll='ls -lah'
alias c='clear'
alias cls='clear'
alias ..='cd ..'
alias ...='cd ../..'

# AWS alias
alias awsuser='aws_current_account'

# Startup hacker drawing
hacker_ascii_art() {
  echo -e "\e[32m
  _    _       _       _     _
 | |  | |     | |     | |   (_)
 | |__| | __ _| |_ ___| |__  _ _ __   __ _
 |  __  |/ _\` | __/ _ \\ '_ \\| | '_ \\ / _\` |
 | |  | | (_| | ||  __/ | | | | | | | (_| |
 |_|  |_|\\__,_|\\__\\___|_| |_|_|_| |_|\\__, |
                                        __/ |
                                       |___/
  Welcome to your terminal, Dr. Swaraj Sir!
  \e[0m"
}

# Bye command with ASCII art
# Bye command with ASCII art
bye_ascii_art() {
  echo -e "\e[36m
  ██████╗ ██╗   ██╗███████╗
  ██╔══██╗██║   ██║██╔════╝
  ██████╔╝██║   ██║███████╗
  ██╔═══╝ ██║   ██║╚════██║
  ██║     ╚██████╔╝███████║
  ╚═╝      ╚═════╝ ╚══════╝
  Goodbye, hacker!
  \e[0m"
  sleep 2  # Wait for 2 seconds
  exit
}


# Call hacker ASCII art on terminal startup
hacker_ascii_art  # Corrected function name

# Alias for bye command
alias bye='bye_ascii_art'

. "$HOME/.local/bin/env"

Usage Examples

1. Check AWS Account

awsuser
# Output: 123456789012

2. Start Docker Desktop

sdocker
# Output: Docker is not running. Starting Docker Desktop...
#         Waiting for Docker to start...
#         Docker is now running!

3. Navigation

cdd
# Navigates to D://projects

4. List Files

ll
# Lists all files in detailed format

5. Reload Configuration

reload
# Reloads the .bashrc file

Contributing

Contributions are welcome! If you have suggestions for improving the script or adding new features:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Feel free to customize further or suggest enhancements!

About

Startup configuration file for Windows Terminal with custom aliases and functions for automation and enhanced productivity.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages