Image

tips

Useful commands

6 min read
Last update: November 28, 2021

Flutter

flutter create --org com.author.application.app --project-name dart_package directory-name

PHP

Linux change PHP version

sudo update-alternatives --config php

Remove node_modules

find . -name 'node_modules' -type d -prune
find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +

Source: https://stackoverflow.com/questions/42950501/delete-node-modules-folder-recursively-from-a-specified-path-using-command-line

MySQL

mysql
CREATE DATABASE my_project_database;
CREATE USER 'my_project_user'@'localhost' IDENTIFIED WITH mysql_native_password BY 'secret_password';
GRANT ALL ON my_project_database.* TO 'my_project_user'@'localhost';
mariadb
CREATE DATABASE `my_project_database`;
CREATE USER 'my_project_user'@localhost IDENTIFIED BY 'super_secret_password';
GRANT ALL privileges ON my_project_database.* TO 'my_project_user'@localhost;
FLUSH PRIVILEGES;

Laravel

Create .env

cp .env.example .env

Download composer dependencies

composer install
composer install --ignore-platform-reqs

Linus setup permissions

sudo chown -R $USER:www-data * ; sudo chmod -R ug+rwx storage bootstrap/cache
sudo chown -R $USER:www-data bookshelves-back
sudo chown -R $USER:www-data bookshelves-vivacia-back

sudo usermod -a -G www-data ewilan

Setup key:generate & storage:link

php artisan key:generate ; php artisan storage:link

Migrate database

php artisan migrate:fresh
php artisan migrate:fresh --seed

Clear all

php artisan cache:clear ; php artisan config:clear ; php artisan route:clear

List routes (compact mode)

php artisan route:list --compact

laravel-ide-helper generate command

php artisan ide-helper:generate ; php artisan ide-helper:models --nowrite; php artisan ide-helper:meta ; php artisan ide-helper:eloquent

PHP-CS-Fixer fix all PHP files

./vendor/bin/php-cs-fixer fix

socket error on serve

In cmd

sudo net stop hns
sudo net star hns

Scoop update

Update common packages

sudo scoop update 7zip cacert composer curl dark doctl ffmpeg firacode git glow hwmonitor innounp lessmsi make ngrok nssm nvm python rufus sudo symfony-cli touch Victor-Mono vim wget which youtube-dl nginx Cascadia-Code

Update language packages

sudo scoop update php-nts php7.3-nts php7.4-nts rust mysql

Update medium/big packages

sudo scoop update discord gimp postman teamviewer vlc

Update mobile development packages

sudo scoop update adb adopt8-hotspot android-sdk android-studio flutter

To update windows-terminal, you need to close it and execute below command from classic PowerShell terminal

sudo scoop update windows-terminal

Configs

Windows terminal

// This file was initially generated by Terminal Windows (décompressé) 1.3.200921001-release1.3
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
    "$schema": "https://aka.ms/terminal-profiles-schema",
    "defaultProfile": "{79285a8e-036c-446f-8a9c-78994e34bf78}",
    "multiLinePasteWarning": false,
    // You can add more global application settings here.
    // To learn more about global settings, visit https://aka.ms/terminal-global-settings
    // If enabled, selections are automatically copied to your clipboard.
    "copyOnSelect": false,
    // If enabled, formatted data is also copied to your clipboard
    "copyFormatting": false,
    "confirmCloseAllTabs": false,
    // A profile specifies a command to execute paired with information about how it should look and feel.
    // Each one of them will appear in the 'New Tab' dropdown,
    //   and can be invoked from the commandline with `wt.exe -p xxx`
    // To learn more about profiles, visit https://aka.ms/terminal-profile-settings
    "profiles": {
        "defaults": {
            // Put settings here that you want to apply to all profiles.
            "fontFace": "MesloLGM NF",
            "colorScheme": "Konsole",
            "acrylicOpacity": 0.8,
            "backgroundImageOpacity": 0.7,
            "backgroundImageStretchMode": "uniformToFill",
            "closeOnExit": false,
            "cursorHeight": 25,
            "cursorShape": "vintage",
            "fontSize": 12,
            "historySize": 9001,
            "padding": "8",
            "snapOnInput": true,
            "startingDirectory": "C:/workspace",
            "useAcrylic": true
        },
        "list": [
            {
                // Make changes here to the powershell.exe profile.
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "name": "Windows PowerShell",
                "commandline": "powershell.exe",
                "padding": "8",
                "hidden": false
            },
            {
                // Make changes here to the cmd.exe profile.
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "name": "Invite de commandes",
                "commandline": "cmd.exe",
                "padding": "8",
                "hidden": false
            },
            {
                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
                "hidden": false,
                "name": "Azure Cloud Shell",
                "source": "Windows.Terminal.Azure"
            },
            {
                "guid": "{79285a8e-036c-446f-8a9c-78994e34bf78}",
                "hidden": false,
                "name": "Konsole",
                // "commandline": "powershell.exe",
                "commandline": "C:\\Program Files (x86)\\PowerShell\\7\\pwsh.exe",
                "icon": "C:/Users/ewila/OneDrive/Documents/WindowsPowerShell/favicon.ico"
            },
            {
                "guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
                "hidden": false,
                "name": "Ubuntu",
                "source": "Windows.Terminal.Wsl"
            },
            {
                "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
                "hidden": false,
                "name": "PowerShell",
                "source": "Windows.Terminal.PowershellCore"
            }
        ]
    },
    // Add custom color schemes to this array.
    // To learn more about color schemes, visit https://aka.ms/terminal-color-schemes
    "schemes": [
        {
            "name": "Konsole",
            //
            "cursorColor": "#00FF00",
            "selectionBackground": "#FFFFFF",
            //
            "background": "#000000",
            "foreground": "#33FF00",
            //
            "black": "#2d3748",
            "blue": "#3465A4",
            "cyan": "#06989A",
            "green": "#b6b6b6",
            "purple": "#75507B",
            "red": "#7a0000",
            "white": "#fff",
            "yellow": "#9c8000",
            "brightBlack": "#fff",
            "brightBlue": "#729FCF",
            "brightCyan": "#34E2E2",
            "brightGreen": "#8AE234",
            "brightPurple": "#AD7FA8",
            "brightRed": "#EF2929",
            "brightWhite": "#b1b1b1",
            "brightYellow": "#FCE94F"
        }
    ],
    // Add custom actions and keybindings to this array.
    // To unbind a key combination from your defaults.json, set the command to "unbound".
    // To learn more about actions and keybindings, visit https://aka.ms/terminal-keybindings
    "actions": [
        // Copy and paste are bound to Ctrl+Shift+C and Ctrl+Shift+V in your defaults.json.
        // These two lines additionally bind them to Ctrl+C and Ctrl+V.
        // To learn more about selection, visit https://aka.ms/terminal-selection
        {
            "command": {
                "action": "copy",
                "singleLine": false
            },
            "keys": "ctrl+c"
        },
        {
            "command": "paste",
            "keys": "ctrl+v"
        },
        // Press Ctrl+Shift+F to open the search box
        {
            "command": "find",
            "keys": "ctrl+shift+f"
        },
        // Press Alt+Shift+D to open a new pane.
        // - "split": "auto" makes this pane open in the direction that provides the most surface area.
        // - "splitMode": "duplicate" makes the new pane use the focused pane's profile.
        // To learn more about panes, visit https://aka.ms/terminal-panes
        {
            "command": {
                "action": "splitPane",
                "split": "auto",
                "splitMode": "duplicate"
            },
            "keys": "alt+shift+d"
        },
        {
            "command": "closePane",
            "keys": [
                "ctrl+w"
            ]
        },
        {
            "command": "newTab",
            "keys": [
                "ctrl+t"
            ]
        }
    ]
}

PowerShell

Invoke-Expression (oh-my-posh --init --shell pwsh --config "$(scoop prefix oh-my-posh)/themes/jandedobbeleer.omp.json")

function ssh-toucan {
    ssh ewilan@server
}

function flutter-clean {
    flutter clean ; flutter pub get
}
function flutter-rebuild {
    flutter clean ; flutter pub get ; flutter run
}
function flutter-build {
    flutter build apk --split-per-abi ; cp build\app\outputs\flutter-apk\app-armeabi-v7a-release.apk
}
function cd {
    cd C:/Users/ewila
}
# Laravel
function artisan-setup {
    composer install ; php artisan key:generate ; php artisan storage:link
    if(!(Test-Path -Path '.env')) {
        New-Item .env
    }
}
function artisan-seed {
    php artisan migrate:fresh --seed
}
function artisan-clear {
    php artisan cache:clear ; php artisan config:clear ; php artisan route:clear ; php artisan view:clear
}
function artisan-routes {
    php artisan route:list --compact
}
function artisan-helper {
    php artisan ide-helper:generate ; php artisan ide-helper:models ; php artisan ide-helper:meta
}
function php-cs-fix {
    ./vendor/bin/php-cs-fixer fix
}
# composer
function composer-v {
    composer --version
}
function composer-($version) {
    composer self-update --$version
}
# php
function php7.2 {
    scoop reset php/php7.2-nts
}
function php7.3 {
    scoop reset php/php7.3-nts
}
function php7.4 {
    scoop reset php/php7.4-nts
}
function php8.0 {
    scoop reset php/php-nts
}

function ll {
    ls
}
function history {
    cat (Get-PSReadlineOption).HistorySavePath
}