Utilizar '터치' en PowerShell
touch index.js
PowerShell을 사용하려면 기능이 필요하지 않으며 PowerShell을 사용할 때 가장 유용해야 합니다.
PowerShell로 터치 구현
Primero, debes abrir tu perfil en tu editor de código favorito, en mi caso es nvim.
nvim $PROFILE
Dentro, debemos colocar el siguiente código.
function Touch-File() {
$fileName = $args[0]
# Comprobar si el archivo existe
if (-not(Test-Path $fileName)) {
# Si no existe, crealo
New-Item -ItemType File -Name $fileName
}
else {
#Si existe, actualiza el timestamp
(Get-ChildItem $fileName).LastWriteTime = Get-Date
}
}
### Creando un alias para touch
# Checar si el alias touch existe
if (-not(Test-Path -Path Alias:Touch)) {
New-Alias -Name Touch Touch-File -Force
}
Estamos haciendo un par de cosas aquí:
Ten en cuenta que no puedes establecer el alias desde dentro de la función, ya que parece que no puede crear un alias para una función que no se ha analizado y vinculado por completeto.
Para probar esto, debes cerrar y abrir una nueva ventana de PowerShell y pruébalo.
touch index.txt
Ahora deberías ver el nuevo archivo creado.
Si quieres ver mas tutoriales como este puedes entrar a mi perfil y ahí encontraras una gran多variadad de tips y tutoriales.👉
Reference
이 문제에 관하여(Utilizar '터치' en PowerShell), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/rogerdimonte/utilizar-touch-en-powershell-4def텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)