Skip to content

Instantly share code, notes, and snippets.

@LukasBombach
Last active January 5, 2024 09:06
Show Gist options
  • Select an option

  • Save LukasBombach/00662c40faaaa0d2cc46ed5f759549a9 to your computer and use it in GitHub Desktop.

Select an option

Save LukasBombach/00662c40faaaa0d2cc46ed5f759549a9 to your computer and use it in GitHub Desktop.

Revisions

  1. LukasBombach revised this gist Jan 5, 2024. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions .zshrc
    Original file line number Diff line number Diff line change
    @@ -41,8 +41,8 @@ function run() {
    echo "\n\033[92m➜\033[0m yarn $command\n"
    yarn "$command"
    elif [ -f "package-lock.json" ]; then
    echo "\n\033[92m➜\033[0m npm $command\n"
    npm "$command"
    echo "\n\033[92m➜\033[0m npm run $command\n"
    npm run "$command"
    else
    echo "No lock file found"
    fi
  2. LukasBombach revised this gist Dec 19, 2023. 1 changed file with 48 additions and 12 deletions.
    60 changes: 48 additions & 12 deletions .zshrc
    Original file line number Diff line number Diff line change
    @@ -25,21 +25,57 @@ function killport() {
    echo "Port" $1 "found and killed."
    }


    # Run a command either by yarn or pnpm depending on the package manager in use
    # I am using yarn as a default because I like it more than npm
    function run() {
    local command="${1:-install}"

    if test -f "yarn.lock"; then
    echo "\n> yarn $command\n"
    yarn $command
    elif test -f "pnpm-lock.yaml"; then
    echo "\n> pnpm $command\n"
    pnpm $command
    else
    echo "\n> yarn $command\n"
    yarn $command
    fi
    local command="${1:-install}"

    if [ -f "bun.lockb" ]; then
    echo "\n\033[92m➜\033[0m bun $command\n"
    bun "$command"
    elif [ -f "pnpm-lock.yaml" ]; then
    echo "\n\033[92m➜\033[0m pnpm $command\n"
    pnpm "$command"
    elif [ -f "yarn.lock" ]; then
    echo "\n\033[92m➜\033[0m yarn $command\n"
    yarn "$command"
    elif [ -f "package-lock.json" ]; then
    echo "\n\033[92m➜\033[0m npm $command\n"
    npm "$command"
    else
    echo "No lock file found"
    fi
    }

    # Clears all caches on the system
    function clear_all_developer_caches() {
    echo "rm -rf ~/.cocoapods/"
    rm -rf ~/.cocoapods/

    echo "pod cache clean --all"
    pod cache clean --all

    echo "yarn cache clean"
    yarn cache clean

    echo "All caches cleared."
    }

    function clear_node_and_next_etc() {
    echo "find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +"
    find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +

    echo "find . -name '.next' -type d -prune -exec rm -rf '{}' +"
    find . -name '.next' -type d -prune -exec rm -rf '{}' +

    echo "find . -name '.expo' -type d -prune -exec rm -rf '{}' +"
    find . -name '.expo' -type d -prune -exec rm -rf '{}' +

    echo "find . -name '.contentlayer' -type d -prune -exec rm -rf '{}' +"
    find . -name '.contentlayer' -type d -prune -exec rm -rf '{}' +

    echo "Cleared all those things"
    }

    # Merge main from the upstream to the current branch and push to origin
  3. LukasBombach revised this gist Jan 9, 2023. 1 changed file with 2 additions and 4 deletions.
    6 changes: 2 additions & 4 deletions .zshrc
    Original file line number Diff line number Diff line change
    @@ -6,19 +6,17 @@ alias zshrc="code ~/.zshrc"
    alias pkg="code ./package.json"

    alias dev="run dev"

    alias build="run build"
    alias start="run start"

    alias grstf="git checkout upstream/main --"


    # Clone a repo into ~/Projects and open code
    function np() {
    if ! test -d "$HOME/Projects/$(basename "$1" .git)" ; then
    git clone "$1" "$HOME/Projects/$(basename "$1" .git)"
    else
    code "$HOME/Projects/$(basename "$1" .git)"
    fi
    code "$HOME/Projects/$(basename "$1" .git)"
    }

    # Kill processes at a given port
  4. LukasBombach revised this gist Jan 6, 2023. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion .zshrc
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,11 @@ alias grstf="git checkout upstream/main --"

    # Clone a repo into ~/Projects and open code
    function np() {
    git clone "$1" "$HOME/Projects/$(basename "$1" .git)" && code "$HOME/Projects/$(basename "$1" .git)"
    if ! test -d "$HOME/Projects/$(basename "$1" .git)" ; then
    git clone "$1" "$HOME/Projects/$(basename "$1" .git)"
    else
    code "$HOME/Projects/$(basename "$1" .git)"
    fi
    }

    # Kill processes at a given port
  5. LukasBombach revised this gist Jan 5, 2023. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions .zshrc
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,15 @@
    # Configure oh my zsh
    alias zshrc="code ~/.zshrc"

    alias pkg="code ./package.json"

    alias dev="run dev"

    alias build="run build"

    alias grstf="git checkout upstream/main --"


    # Clone a repo into ~/Projects and open code
    function np() {
    git clone "$1" "$HOME/Projects/$(basename "$1" .git)" && code "$HOME/Projects/$(basename "$1" .git)"
  6. LukasBombach revised this gist Jan 5, 2023. 1 changed file with 17 additions and 17 deletions.
    34 changes: 17 additions & 17 deletions .zshrc
    Original file line number Diff line number Diff line change
    @@ -14,6 +14,23 @@ function killport() {
    echo "Port" $1 "found and killed."
    }

    # Run a command either by yarn or pnpm depending on the package manager in use
    # I am using yarn as a default because I like it more than npm
    function run() {
    local command="${1:-install}"

    if test -f "yarn.lock"; then
    echo "\n> yarn $command\n"
    yarn $command
    elif test -f "pnpm-lock.yaml"; then
    echo "\n> pnpm $command\n"
    pnpm $command
    else
    echo "\n> yarn $command\n"
    yarn $command
    fi
    }

    # Merge main from the upstream to the current branch and push to origin
    function gmu() {
    echo ""
    @@ -31,23 +48,6 @@ function gmu() {
    echo ""
    }

    # Run a command either by yarn or pnpm depending on the package manager in use
    function run() {
    local command="${1:-install}"

    if test -f "yarn.lock"; then
    echo "\n> yarn $command\n"
    yarn $command
    elif test -f "pnpm-lock.yaml"; then
    echo "\n> pnpm $command\n"
    pnpm $command
    else
    # using yarn as a default because I like it more than npm
    echo "\n> yarn $command\n"
    yarn $command
    fi
    }

    # nvm with automatic node version switch based on the .nvmrc of a directory
    export NVM_DIR="$HOME/.nvm"
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
  7. LukasBombach revised this gist Jan 5, 2023. 1 changed file with 60 additions and 10 deletions.
    70 changes: 60 additions & 10 deletions .zshrc
    Original file line number Diff line number Diff line change
    @@ -3,21 +3,71 @@
    # Configure oh my zsh
    alias zshrc="code ~/.zshrc"

    # Kill a process at port x
    function killport() {
    lsof -i TCP:$1 | grep LISTEN | awk '{print $2}' | xargs kill -9
    echo "Port" $1 "found and killed."
    }

    # Clone a repo into ~/Projects and open code
    function np() {
    git clone "$1" "$HOME/Projects/$(basename "$1" .git)" && code "$HOME/Projects/$(basename "$1" .git)"
    }

    # Kill processes at a given port
    function killport() {
    lsof -i TCP:$1 | grep LISTEN | awk '{print $2}' | xargs kill -9
    echo "Port" $1 "found and killed."
    }

    # Merge main from the upstream to the current branch and push to origin
    function gmu() {
    echo "git fetch upstream"
    echo ""
    echo "> git pull origin $(current_branch)"
    git pull origin $(current_branch)
    echo ""
    echo "> git fetch upstream"
    git fetch upstream
    echo "git merge upstream/main --no-edit && git push origin $(current_branch)"
    git merge upstream/main --no-edit && git push origin $(current_branch)
    }
    echo ""
    echo "> git merge upstream/main --no-edit"
    git merge upstream/main --no-edit
    echo ""
    echo "> git push origin $(current_branch)"
    git push origin $(current_branch)
    echo ""
    }

    # Run a command either by yarn or pnpm depending on the package manager in use
    function run() {
    local command="${1:-install}"

    if test -f "yarn.lock"; then
    echo "\n> yarn $command\n"
    yarn $command
    elif test -f "pnpm-lock.yaml"; then
    echo "\n> pnpm $command\n"
    pnpm $command
    else
    # using yarn as a default because I like it more than npm
    echo "\n> yarn $command\n"
    yarn $command
    fi
    }

    # nvm with automatic node version switch based on the .nvmrc of a directory
    export NVM_DIR="$HOME/.nvm"
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

    autoload -U add-zsh-hook
    load-nvmrc() {
    local nvmrc_path="$(nvm_find_nvmrc)"

    if [ -n "$nvmrc_path" ]; then
    local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")

    if [ "$nvmrc_node_version" = "N/A" ]; then
    nvm install
    elif [ "$nvmrc_node_version" != "$(nvm version)" ]; then
    nvm use
    fi
    elif [ -n "$(PWD=$OLDPWD nvm_find_nvmrc)" ] && [ "$(nvm version)" != "$(nvm version default)" ]; then
    echo "Reverting to nvm default version"
    nvm use default
    fi
    }
    add-zsh-hook chpwd load-nvmrc
    load-nvmrc
  8. LukasBombach revised this gist Oct 18, 2022. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions .zshrc
    Original file line number Diff line number Diff line change
    @@ -13,3 +13,11 @@ function killport() {
    function np() {
    git clone "$1" "$HOME/Projects/$(basename "$1" .git)" && code "$HOME/Projects/$(basename "$1" .git)"
    }

    # Merge main from the upstream to the current branch and push to origin
    function gmu() {
    echo "git fetch upstream"
    git fetch upstream
    echo "git merge upstream/main --no-edit && git push origin $(current_branch)"
    git merge upstream/main --no-edit && git push origin $(current_branch)
    }
  9. LukasBombach created this gist Oct 18, 2022.
    15 changes: 15 additions & 0 deletions .zshrc
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    # My oh my zsh aliases and functions

    # Configure oh my zsh
    alias zshrc="code ~/.zshrc"

    # Kill a process at port x
    function killport() {
    lsof -i TCP:$1 | grep LISTEN | awk '{print $2}' | xargs kill -9
    echo "Port" $1 "found and killed."
    }

    # Clone a repo into ~/Projects and open code
    function np() {
    git clone "$1" "$HOME/Projects/$(basename "$1" .git)" && code "$HOME/Projects/$(basename "$1" .git)"
    }