Created
February 11, 2024 15:03
-
-
Save adiog/f68f842a36e79208d4c9cfadb5a322b1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$MARKS_DIR = "$HOME/.powermarks" | |
$MARKS_CWD = ".cwd" | |
New-Item -ItemType Director -Force -Path $MARKS_DIR | |
function _l() { | |
Get-ChildItem -Path $MARKS_DIR | |
} | |
function _m($MARK_LABEL) { | |
Get-Location | Set-Content "$MARKS_DIR/$MARK_LABEL" | |
} | |
function m($MARK_LABEL) { | |
if ($MARK_LABEL) { _m $MARK_LABEL} else { _m $MARKS_CWD } | |
} | |
function d($MARK_LABEL) { | |
Remove-Item "$MARKS_DIR/$MARK_LABEL" | |
} | |
function l(){ | |
Get-ChildItem -Path $MARKS_DIR | ForEach-Object { Write-Output "[$($_.name)] [$(Get-Content $_)]" } | |
} | |
function g($MARK_LABEL) { | |
if ($MARK_LABEL) { | |
$MarkedPath = "$MARKS_DIR/$MARK_LABEL" | |
if (Test-Path "$MarkedPath") { cd "$(Get-Content $MarkedPath)" } else { Write-Output "Missing Bookmark $MarkedPath" } | |
} else { | |
$MarkedPath = "$MARKS_DIR/$MARKS_CWD" | |
cd "$(Get-Content $MarkedPath)" | |
} | |
} | |
Function psrgrep($pattern) { | |
Get-ChildItem -File -Recurse | ForEach-Object { Select-String -Pattern $pattern -Path $_ } | |
} | |
Function psfind($folder, $template) { | |
echo "Get-ChildItem -Path $folder -Name $template -Recurse" | |
Get-ChildItem -Path $folder -Name $template -Recurse | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment