Linux
Zshrc Config

My zsh config.

To edit vim ~/.zshrc

alias addshad='./add-components.sh'
alias vim='nvim'
alias szsh='source ~/.zshrc'
 
## run scraper
export PYTHONSCRAPER='~/sites/whatsapp-flask-scraper/'
 
alias scraper='cd ~/sites/PYTHONSCRAPER '
alias dev='cd /home/remcostoeten/development'
 
pr_create() {
    local target_branch="$1"
    shift # Move to the next argument
    local input="$*"
 
    # Check if the target branch is provided
    if [[ -z "$target_branch" ]]; then
        echo "Error: Please provide a target branch."
        return 1
    fi
 
    # Get the current branch
    local current_branch
    current_branch=$(git symbolic-ref --short HEAD)
 
    # Check if there are at least two arguments separated by '/'
    if [[ -z "$input" || ! "$input" == */* ]]; then
        echo "Error: Please provide a title and description separated by '/'."
        return 1
    fi
 
    # Extract title and description from the input
    local IFS='/'
    read -r title description <<<"$input"
 
    # Run the gh command
 
    gh pr create --base "$target_branch" --head "$current_branch" --title "$title" --body "$description"
}
 
delete_branch() {
    local branch_name="$1"
 
    # Get the current branch
    local current_branch=$(git symbolic-ref --short HEAD 2>/dev/null)
 
    # Check if the current branch is the one to be deleted
    if [ "$current_branch" = "$branch_name" ]; then
        # Fallback branch in case the current branch is to be deleted
        local fallback_branch="master"  # You can change this to 'dev' or any other fallback branch you prefer
 
        # Check if the fallback branch exists
        if git rev-parse --verify "$fallback_branch" >/dev/null 2>&1; then
            git checkout "$fallback_branch"
        else
            echo "Fallback branch '$fallback_branch' not found. Unable to switch branches."
            return 1
        fi
    fi
 
    # Confirming before creating a merge request
    read -r "?Do you want to create a merge request before deleting branch '$branch_name'? [y/N] " create_mr
 
    if [[ "$create_mr" =~ ^[Yy]$ ]]; then
        # Check if gh cli is installed
        if ! command -v gh &>/dev/null; then
            echo "GitHub CLI (gh) is required to create a merge request."
            return 1
        fi
 
        # Create a merge request using gh cli
        gh pr create --base "$fallback_branch" --head "$branch_name" --title "Merge $branch_name into $fallback_branch" --body "Please review and merge this branch before deletion."
        echo "Merge request created successfully."
    fi
 
    # Confirming before deletion
    read -r "?Are you sure you want to delete branch '$branch_name' locally and remotely? [y/N] " response
 
    # Check if the response is affirmative
    if [[ "$response" =~ ^[Yy]$ ]]; then
        # Deleting locally
        git branch -d "$branch_name"
 
        # Deleting remotely
        git push origin --delete "$branch_name"
 
        echo "Branch '$branch_name' deleted locally and remotely."
    else
        echo "Operation aborted."
    fi
}
 
 
 
alias delbranch=delete_branch
 
 
alias pr="pr_create"
alias cpp='f() { git add *; git commit -m "$1"; git push; unset -f f; }; f'
alias devstack='cd ~/sites/pleio-dev-stack/frontend && nohup yarn && yarn start & cd .. && nohup docker-compose up &'
# Define environment variables
export REMCO=REMCOSTOETEN_DIR
export PORTFOLIO=Portfolio-Grid-UI
# Variables for personal website, Pleio dev stack, and snippets
export PERSONAL_WEBSITE=~/sites/$REMCO/$PORTFOLIO
export PLEIO_DIR=~/sites/pleio-dev-stack
export SNIPPETS=~/snippets.remcostoeten
export CURRENTSITE=~/sites/$REMCO$PORTFOLIO
export ALARM=/home/remcostoeten/Music/alarm.mp3
 
 
 
# Define a function that executes the shell script
echo_pipe_operator() {
  bash ~/sites/REMCOSTOETEN_DIR/custom-shell-scripts/echo-pipe-operator.sh
}
 
echo_escape_remap() {
  bash /home/remcostoeten/sites/REMCOSTOETEN_DIR/shell-scripts
/remap_cap_with_escape.sh
}
zle A echo_escape_remap
#super to mouse left
simulate_super() {
    xdotool key Super_L
}
 
alias codezsh='code ~/.zshrc'
 
bindkey 'A' echo_pipe_operator
# Replace 'KEYSEQUENCE' with the actual key sequence for Ctrl + Shift + A in your terml
 
 
alias catcopy="cat ~/filex | pbcopy"
alias copypwd='pwd | xclip -selection clipboard'
alias copyfilename='echo $PWD | xclip -selection clipboard'
 
bindkey -s '\e[1;3;32~' 'simulate_super\n'
 
 
# Use zle to create a new widget that calls the function
zle -N echo_pipe_operator
 
# Bind the key sequence to the widget
bindkey '^A' echo_pipe_operator
# Replace 'KEYSEQUENCE' with the actual key sequence for Ctrl + Shift + A in your terml
 
 
alias click='/home/remcostoeten/sites/REMCOSTOETEN_DIR/shell-scripts/click.sh'
gi() {
  git add -A && git commit -m "$*"
}
git_add_commit_push() {
 git add *  ;  git commit -m "$1" ; git push
}
 
#######################/#
#                      #
#   custom functions   #
#                      #
########################
 
alias alarm=countdown_timer
 
alias python=python3
alias p=python3
alias pleio='cd /home/remcostoeten/development/pleio-dev-stack'
alias code='code .'
alias codex='code .; xx'
alias branch='git branch'
alias checkout='git checkout'
alias pull='git pull'
alias push='git push'
alias status='git status'
alias reset='git reset --hard'
 
# Function to create a countdown timer
countdown_timer() {
    local ALARMFILE=~/Music/alarm.mp3
 
    # Function to parse a time unit and convert it to seconds
    parse_unit_to_seconds() {
        unit=$1
        value=${unit%[a-z]*}
        unit_type=${unit##*[0-9]}
        case $unit_type in
        s) echo $value ;;
        m) echo $((value * 60)) ;;
        h) echo $((value * 3600)) ;;
        *) echo 0 ;;
        esac
    }
 
    # Calculate the total time in seconds from the input arguments
    local total_seconds=0
    for arg in "$@"; do
        seconds=$(parse_unit_to_seconds $arg)
        if [ $seconds -eq 0 ]; then
            echo "Invalid input. Please use 'X hours' or 'X minutes' or 'X seconds.'"
            return 1
        fi
        total_seconds=$((total_seconds + seconds))
    done
 
    # Countdown loop
    while [ $total_seconds -gt 0 ]; do
        if [ $total_seconds -eq 2 ]; then
            echo "Hi"
        fi
 
        echo "Time remaining: $total_seconds seconds"
        sleep 1
        total_seconds=$((total_seconds - 1))
    done
 
    # Open the default audio player to play the alarm MP3 file when the countdown reaches 0 seconds
    if [ $total_seconds -eq 0 ]; then
        xdg-open $ALARMFILE
    fi
 
    # Display a notification message when the countdown reaches 0 using zenity
    zenity --info --text="Countdown Timer: Time's up!"
}
 
# Git add and commit function with a custom commit message
addcommit() {
    git add .
    local commit_message=""
 
    for arg in "$@"; do
        commit_message="$commit_message $arg"
    done
 
    shift "$(($# > 0 ? 1 : 0))"
 
    git commit -m "$commit_message"
}
#alias build='rm -rf node_modules ; rm -rf .next ; bun run build'
alias bbuild='rm -rf ./next ; rm -rf node_modules; bun i ;  bun run build'
alias pbuild='rm -rf ./next ; rm -rf node_modules; pnpm i ;  pnpm run build'
alias open='open .'
 
alias lint='bun run lint'
alias format='bun run format:write'
alias typecheck='bun run typecheck'
 
# Git add, commit, and push function with a custom commit message
addcommitpush() {
    git add .
    local commit_message=""
 
    for arg in "$@"; do
        commit_message="$commit_message $arg"
    done
 
    shift "$(($# > 0 ? 1 : 0))"
 
    git commit -m "$commit_message"
 
    git push
}
# Function to create a file with specified content and filename
createfile() {
    if [ $# -lt 2 ]; then
        echo "Usage: createfile <content> <filename>"
        return 1
    fi
 
    local content="$1"
    local filename="$2"
 
    echo "$content" >"$filename"
}
 
########################
#                      #
#   custom aliases     #
#                      #
########################
 
#######terminal########
 
# reboot and shutdown
alias reboot='sudo reboot --force'
 
# Clear the terminal
alias cc="clear"
# Exit the terminal
alias xx="exit"
# Remove a file or directory recursively and forcefully
alias rmrf="rm -rf"
alias r='rm -rf'
# Create a file with specified content and filename
alias file='createfile'
# Display system processes in real-time
alias top='htop'
# Run a command with sudo privileges
alias s="sudo /home/remcostoeten/sites/shell-script/sudo.sh"' >> ~/.bashrc'
#######Docker###########
 
# Stop all running Docker containers
alias stopdocker='docker-compose down && docker stop $(docker ps -aq)'
# Remove all Docker containers
alias rmcontainers='docker rm $(docker ps -aq)'
# Run a Docker container with a specific configuration
alias runfsv="cd ~/sites/dossier && git pull && code .  &&  docker-compose up"
# Start a Docker container
alias dstart="docker-compose up"
#run api pleio only
alias pbstart="cd ~/sites/pleio/ && docker-compose up api"
#start zshrc
alias zsh="vim ~/.zshrc"
#run frontend pleio
alias pfstart="cd ~/sites/pleio/frontend && yarn && yarn start"
# Stop a Docker container
alias dstop="docker-compose down"
# Show running Docker containers
alias dshow="docker ps"
# Show logs of a Docker container
alias dlog="docker-compose losg -f --tail=4"
 
######Run site#########
 
# Run a development server for a website
 
alias rundocs="cd ~/sites/$REMCO/$SNIPPETS && code . && bun run dev;"
# Run a development server for Pleio
alias runp="cd $PLEIO_DIR; cd frontend; code . ; docker-compose up"
# Run a development server for personal website
alias runsite="cd $PERSONAL_WEBSITE && rmrf .next node_modules; bun i ;  code . && bun run dev"
#go to shell scripts
alias shell="cd ~/sites/$REMCO/shell-scripts"
# Go to Pleio directory
alias pull='git pull'
alias push='git push'
alias reset='git reset --hard'
alias checkout='git checkout'
alias gop="cd $PLEIO_DIR"
alias gopf="cd $PLEIO_DIR/frontend"
# Go to personal website directory
alias gor="cd $PERSONAL_WEBSITE"
# Run a development server
alias run="code . &&  bun run dev"
# Restart a development server
alias restart="rm -rf node_modules/&& rm -rf .next/ &&  pnpm install &&  code .  &&  pnpm run dev"
# Rebuild a development server
alias rebuild="rm -rf node_modules/ &&  rm -rf .nextndkey
//home/remcostoeten/sites/REMCOSTOETEN_DIR/shell-scripts; ./click.sh"
# Autoclick very fast
alias clickfast="cd /home/remcostoeten/sites/REMCOSTOETEN_DIR/shell-scripts; ./click.sh -t 500 -s 0.5"
# Autoclick slow
alias clickslow="cd /home/remcostoeten/sites/REMCOSTOETEN_DIR/shell-scripts; ./click.sh -t 500 -s 2.5"
 
# Allow execution of a file with sudo privileges
alias allow='sudo chmod +x $1'
# Connect to a VPN using Tailscale
alias vpn="tailscale"
# Go to Desktop directory
alias d="cd ~/Desktop"
# Translate JSON files using a translation service
alias translate="yarn json-autotranslate --input src/js/i18n/messages/ --type key-based --matcher i18next --directory-structure ngx-translate --service deepl-free --config fb9ed0cc-2782-eaa0-d75b-76d5f8f92f87:fx,less --delete-unused-strings"
# Open a custom cursor application
alias cursor="cd ~/Programs && ./cursor.AppImage"
 
# Set ZSH configuration
export ZSH=~/.oh-my-zsh
# Set a random theme for the terminal
# PS1='%B%{$fg[yellow]%}%~/ %{$fg_bold[cyan]%}$(git_prompt_info)%{$fg_bold[blue]%}
# %{$reset_color%}%B'
# RPROMPT='%T'
# ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}"
# ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
# ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$fg[green]%}"
# ZSH_THEME="dstufft"
ZSH_THEME="duellj"
 
# Set list of themes to load
plugins=(
    git
    nvm
    aliases
    colorize
    zsh-autosuggestions
    gh
    sudo
    zsh-syntax-highlighting
    extract
    web-search
    history-substring-search
)
 
 
# Set completion options
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
source ~/.oh-my-zsh/oh-my-zsh.sh
 
# bun completions
[ -s "/home/remcostoeten/.bun/_bun" ] && source "/home/remcostoeten/.bun/_bun"
 
# bun
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
[[ -s /usr/share/autojump/autojump.zsh ]] && source /usr/share/autojump/autojump.zsh
 
# pnpm
export PNPM_HOME="/home/remcostoeten/.local/share/pnpm"
case ":$PATH:" in
  *":$PNPM_HOME:"*) ;;
  *) export PATH="$PNPM_HOME:$PATH" ;;
esac
# pnpm end
 
PATH=~/.console-ninja/.bin:$PATH
 
 

old

 
alias vim='nvim'
alias szsh='source ~/.zshrc'
 
 
pr_create() {
    local target_branch="$1"
    shift # Move to the next argument
    local i add  nput="$*"
 
    # Check if the target branch is provided
    if [[ -z "$target_branch" ]]; then
        echo "Error: Please provide a target branch."
        return 1
    fi
 
    # Get the current branch
    local current_branch
    current_branch=$(git symbolic-ref --short HEAD)
 
    # Check if there are at least two arguments separated by '/'
    if [[ -z "$input" || ! "$input" == */* ]]; then
        echo "Error: Please provide a title and description separated by '/'."
        return 1
    fi
 
    # Extract title and description from the input
    local IFS='/'
    read -r title description <<<"$input"
 
    # Run the gh command
 
    gh pr create --base "$target_branch" --head "$current_branch" --title "$title" --body "$description"
}
 
alias pr="pr_create"
 
alias devstack='cd ~/sites/pleio-dev-stack/frontend && nohup yarn && yarn start & cd .. && nohup docker-compose up &'
# Define environment variables
export REMCO=REMCOSTOETEN_DIR
export PORTFOLIO=Portfolio-Grid-UI
# Variables for personal website, Pleio dev stack, and snippets
export PERSONAL_WEBSITE=~/sites/$REMCO/$PORTFOLIO
export PLEIO_DIR=~/sites/pleio-dev-stack
export SNIPPETS=~/snippets.remcostoeten
export CURRENTSITE=~/sites/$REMCO$PORTFOLIO
export ALARM=/home/remcostoeten/Music/alarm.mp3
 
########################
#                      #
#   custom functions   #
#                      #
########################
alias alarm=countdown_timer
 
# Function to create a countdown timer
# Function to create a countdown timer
countdown_timer() {
    local ALARMFILE=~/Music/alarm.mp3
 
    # Function to parse a time unit and convert it to seconds
    parse_unit_to_seconds() {
        unit=$1
        value=${unit%[a-z]*}
        unit_type=${unit##*[0-9]}
        case $unit_type in
        s) echo $value ;;
        m) echo $((value * 60)) ;;
        h) echo $((value * 3600)) ;;
        *) echo 0 ;;
        esac
    }
 
    # Calculate the total time in seconds from the input arguments
    local total_seconds=0
    for arg in "$@"; do
        seconds=$(parse_unit_to_seconds $arg)
        if [ $seconds -eq 0 ]; then
            echo "Invalid input. Please use 'X hours' or 'X minutes' or 'X seconds.'"
            return 1
        fi
        total_seconds=$((total_seconds + seconds))
    done
 
    # Countdown loop
    while [ $total_seconds -gt 0 ]; do
        if [ $total_seconds -eq 2 ]; then
            echo "Hi"
        fi
 
        echo "Time remaining: $total_seconds seconds"
        sleep 1
        total_seconds=$((total_seconds - 1))
    done
 
    # Open the default audio player to play the alarm MP3 file when the countdown reaches 0 seconds
    if [ $total_seconds -eq 0 ]; then
        xdg-open $ALARMFILE
    fi
 
    # Display a notification message when the countdown reaches 0 using zenity
    zenity --info --text="Countdown Timer: Time's up!"
}
 
# Git add and commit function with a custom commit message
addcommit() {
    git add .
    local commit_message=""
 
    for arg in "$@"; do
        commit_message="$commit_message $arg"
    done
 
    shift "$(($# > 0 ? 1 : 0))"
 
    git commit -m "$commit_message"
}
 
alias build='rm -rf ./next ; rm -rf node_modules; bun i ;  bun run build'
# Git add, commit, and push function with a custom commit message
addcommitpush() {
    git add .
    local commit_message=""
 
    for arg in "$@"; do
        commit_message="$commit_message $arg"
    done
 
    shift "$(($# > 0 ? 1 : 0))"
 
    git commit -m "$commit_message"
 
    git push
}
# Function to create a file with specified content and filename
createfile() {
    if [ $# -lt 2 ]; then
        echo "Usage: createfile <content> <filename>"
        return 1
    fi
 
    local content="$1"
    local filename="$2"
 
    echo "$content" >"$filename"
}
 
########################
#                      #
#   custom aliases     #
#                      #
########################
 
#######terminal########
 
# Clear the terminal
alias cc="clear"
# Exit the terminal
alias xx="exit"
# Remove a file or directory recursively and forcefully
alias rmrf="rm -rf"
# Create a file with specified content and filename
alias file='createfile'
# Display system processes in real-time
alias top='htop'
# Run a command with sudo privileges
alias s="sudo /home/remcostoeten/sites/shell-script/sudo.sh"' >> ~/.bashrc'
#######Docker###########
 
# Stop all running Docker containers
alias stopdocker='docker-compose down && docker stop $(docker ps -aq)'
# Remove all Docker containers
alias rmcontainers='docker rm $(docker ps -aq)'
# Run a Docker container with a specific configuration
alias runfsv="cd ~/sites/dossier && git pull && code .  &&  docker-compose up"
# Start a Docker container
alias dstart="docker-compose up"
#run api pleio only
alias pbstart="cd ~/sites/pleio/ && docker-compose up api"
#start zshrc
alias zsh="vim ~/.zshrc"
#run frontend pleio
alias pfstart="cd ~/sites/pleio/frontend && yarn && yarn start"
# Stop a Docker container
alias dstop="docker-compose down"
# Show running Docker containers
alias dshow="docker ps"
# Show logs of a Docker container
alias dlog="docker-compose losg -f --tail=4"
 
######Run site#########
 
# Run a development server for a website
 
alias rundocs="cd ~/sites/$REMCO/$SNIPPETS && code . && bun run dev;"
# Run a development server for Pleio
alias runp="cd $PLEIO_DIR; cd frontend; code . ; docker-compose up"
# Run a development server for personal website
alias runsite="cd $PERSONAL_WEBSITE && rmrf .next node_modules; bun i ;  code . && bun run dev"
#go to shell scripts
alias shell="cd ~/sites/$REMCO/shell-scripts"
# Go to Pleio directory
alias pull='git pull'
alias push='git push'
alias reset='git reset --hard'
alias checkout='git checkout'
alias gop="cd $PLEIO_DIR"
alias gopf="cd $PLEIO_DIR/frontend"
# Go to personal website directory
alias gor="cd $PERSONAL_WEBSITE"
# Run a development server
alias run="code . &&  bun run dev"
# Restart a development server
alias restart="rm -rf node_modules/&& rm -rf .next/ &&  pnpm install &&  code .  &&  pnpm run dev"
# Rebuild a development server
alias rebuild="rm -rf node_modules/ &&  rm -rf .next/ &&  pnpm i  && pnpm run build"
# Run a development server with a custom command
alias br="bun run dev"
# Run a build command with a custom command
alias bb="bun run build"
 
####Git################
 
# Add and commit changes with a custom commit message
alias c='addcommit'
# Add, commit, and push changes with a custom commit message
alias cpp='addcommitpush'
# Git reset --hard shortcut
alias reset-='git reset --hard'
alias gcc='checkout'
####Copy content#######
 
# Copy the contents of a file to the clipboard
alias catcopy='cat $1 | xclip -selection clipboard'
# Display the contents of a file with syntax highlighting
alias cat="bat" #requires
 
####Misc################
alias copyremote="git remote -v | awk '{print $2}' | uniq | xclip -selection clipboard"
 
# Sudo apt-get install alias
alias install="sudo apt-get install"
 
# Prisma shorthand aliasses
alias prismapush="npx prisma db push"
alias prismapull="npx prisma db pull"
alias prismagen="npx prisma generate"
alias migratedev="npx prisma migrate dev"
 
# Autoclicker
alias click="cd /home/remcostoeten/sites/REMCOSTOETEN_DIR/shell-scripts; ./click.sh"
# Autoclick very fast
alias clickfast="cd /home/remcostoeten/sites/REMCOSTOETEN_DIR/shell-scripts; ./click.sh -t 500 -s 0.5"
# Autoclick slow
alias clickslow="cd /home/remcostoeten/sites/REMCOSTOETEN_DIR/shell-scripts; ./click.sh -t 500 -s 2.5"
 
# Run a development server with npm or pnpm
alias dev="npm | pnpm run dev"
# Allow execution of a file with sudo privileges
alias allow='sudo chmod +x $1'
# Connect to a VPN using Tailscale
alias vpn="tailscale"
# Go to Desktop directory
alias d="cd ~/Desktop"
# Translate JSON files using a translation service
alias translate="yarn json-autotranslate --input src/js/i18n/messages/ --type key-based --matcher i18next --directory-structure ngx-translate --service deepl-free --config fb9ed0cc-2782-eaa0-d75b-76d5f8f92f87:fx,less --delete-unused-strings"
# Open a custom cursor application
alias cursor="cd ~/Programs && ./cursor.AppImage"
 
# Set ZSH configuration
export ZSH=~/.oh-my-zsh
# Set a random theme for the terminal
PS1='%B%{$fg[yellow]%}%~/ %{$fg_bold[cyan]%}$(git_prompt_info)%{$fg_bold[blue]%}
%{$reset_color%}%B'
RPROMPT='%T'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$fg[green]%}"
 
# Set list of themes to load
plugins=(
    git
    nvm
    aliases
    colorize
    zsh-autosuggestions
    gh
    sudo
    zsh-syntax-highlighting
)
 
# Set completion options
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
source ~/.oh-my-zsh/oh-my-zsh.sh
 
# bun completions
[ -s "/home/remcostoeten/.bun/_bun" ] && source "/home/remcostoeten/.bun/_bun"
 
# bun
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
[[ -s /usr/share/autojump/autojump.zsh ]] && source /usr/share/autojump/autojump.zsh
'