Install Windows Subsystem for Linux to get a Linux shell for Windows.
Enter wsl
into PowerShell (or your shell of choice) to get started.
The search term font-size: 12px
is just an example; replace this text with the search pattern.
grep -Rnw . -e 'font-size: 12px';
Source: rakib and CodeWizard on StackOverflow
du -h --threshold=1G
du -sh -- * | sort -h
Such as 644, 777.
stat -c "%a %n" *
eval "$(ssh-agent -s)"
ssh-add /mnt/c/Users/Username/.ssh/private_openssh
rsync
: Sync folders and files between a remote server and a local server.
Examples:
- Sync from a remote server to a local server.
- Sync between 2 remote servers.
- WordPress usage: Sync uploads, themes, and plugins.
Source (Remote): [email protected]:/www/path/public/shared/web/app/uploads/
Destination (Local): /mnt/c/destination/uploads/
(also known as C:\destination\uploads
)
rsync -av --dry-run -e 'ssh -i /local/path/to/public_id_rsa -p 22' [email protected]:/source/home/username/domains/example.com/shared/web/app/uploads /mnt/c/destination/uploads/
Remove the --dry-run
flag.
rsync -av --progress --delete -e 'ssh -i /path/to/id_rsa -p 22' /mnt/c/source/themes/my-theme/ username@IP:/destination/home/username/domains/example.com/path/to/themes/my-theme/
Notes:
- Add the
--dry-run
flag to test the SSH connection from the shell and show which files will be transferred. - The
$HOME
variable will not be the same locally and remotely. - The trailing
/
inuploads/
performs an inner copy, targeting all the files and folders inside ofuploads
. If the trailing forward slash "/
" were omitted, then a new folder would be created inside of the destinationuploads
folder:/mnt/c/source/uploads/uploads/
- Consider adding the
--progress
flag. - Carefully consider adding the
--delete
flag to delete files from the destination, which are not present in the source. Use--delete
with caution to avoid losing data!- I generally only use
--delete
to sync development uploads with production so that it exactly matches production. - Another common use for
--delete
is backing up plugin folders before testing new versions. And if the new plugin files need to be overwritten, the--delete
flag removes any new files.
- I generally only use
Push to a remote subtree.
git subtree push --prefix=path/to/subdir remote-name ref
For example: A static site generator uses a separate remote repository for its theme files.
- The path/to/subdir theme is installed at
themes/theme-name
. - The remote-name was established with
git remote add -f theme-name https://github.com/username/theme-name.git
- The ref could be
master
,main
, or whichever branch on the remote to be targeted.
Edit the ~/.bashrc
file using your editor of choice.
Add an export statement to .bashrc
, defining:
- green-text,
- the most current folder in path,
- a couple of spaces, and
- the $ sign.
export PS1="\[\033[01;32m\]\W \\$ \[$(tput sgr0)\]"
CTRL+L
CTRL+SHFT+L
$HOME/AppData/Roaming/Code/User/settings.json
Assuming that Get-ExecutionPolicy -List
returns RemoteSigned
for the current scope, add a prompt
function to your PowerShell profile.
Choose your own colors
C:\Users\MyUserName\Documents\WindowsPowerShell\profile.ps1
function prompt {
$Host.ui.rawui.foregroundcolor = "Green"
"$([char]27)[1m" + $(Get-Location).Path.Substring((Get-Location).Path.LastIndexOf("\")+1) + " > "
}
Too many nested elements? Press CTRL
+ K
+ 0
to collapse everything, and CTRL
+ J
+ 0
to expand.
Go to the problem with CTRL
+ SHIFT
+ M
Within an HTML file, press !
+ TAB
CTRL
+ /
(or)
CTRL
+ K
+ C
to comment.
CTRL
+ K
+ U
to un-comment.
Command Line Interface for WordPress.
Install this WP-CLI extension: wp-cli-dotenv-command
Use the wp dotenv init
command to create a new environment file with salts:
wp dotenv init --template=".env.example" --with-salts
wp plugin update --all --dry-run