From 4bb3ad4ec680ffdfab3b5d6f8f8409b00033358d Mon Sep 17 00:00:00 2001 From: Kia Raad Date: Tue, 29 Oct 2024 22:03:26 +0330 Subject: [PATCH 1/3] Cleanup and categorize the content --- .github/wiki/Getting-Started.md | 51 +++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/.github/wiki/Getting-Started.md b/.github/wiki/Getting-Started.md index e3a326f71..1b93a9384 100644 --- a/.github/wiki/Getting-Started.md +++ b/.github/wiki/Getting-Started.md @@ -5,8 +5,9 @@ Onefetch is installed, then what? ```sh > onefetch /path/of/your/repo ``` + Or - + ```sh > cd /path/of/your/repo > onefetch @@ -15,28 +16,37 @@ Onefetch is installed, then what? ### Misc By [**@spenserblack**](https://github.com/spenserblack) + ```sh # Runs `onefetch -a Assembly`, `onefetch -a C`, etc. onefetch -l | tr "[:upper:] " "[:lower:]-" | while read line; do echo "$line"; onefetch -a $line; done; ``` -By [**@quazar-omega**](https://github.com/quazar-omega) + +### Automatic repo detection and running + +If you want to automate the detection and running of `onefetch` every time you `cd` into a repository you can leverage one of the methods below: + +#### 1. Bash / Zsh + +> By [**@quazar-omega**](https://github.com/quazar-omega) A script to put in your `.bashrc` - or `.zshrc` - to run onefetch whenever you open a shell into a repository or `cd` into a repository, making sure that it's different from the last one you were in: + ```sh # git repository greeter last_repository= check_directory_for_new_repository() { - current_repository=$(git rev-parse --show-toplevel 2> /dev/null) - - if [ "$current_repository" ] && \ - [ "$current_repository" != "$last_repository" ]; then - onefetch - fi - last_repository=$current_repository + current_repository=$(git rev-parse --show-toplevel 2> /dev/null) + + if [ "$current_repository" ] && \ + [ "$current_repository" != "$last_repository" ]; then + onefetch + fi + last_repository=$current_repository } cd() { - builtin cd "$@" - check_directory_for_new_repository + builtin cd "$@" + check_directory_for_new_repository } # optional, greet also when opening shell directly in repository directory @@ -44,9 +54,12 @@ cd() { check_directory_for_new_repository ``` -By [**@TheSast**](https://github.com/TheSast) +#### 2. Fish + +> By [**@TheSast**](https://github.com/TheSast) A fish adaptation of the previous script, run it once in your shell to save it: + ```fish function cd -w='cd' builtin cd $argv || return @@ -66,11 +79,14 @@ funcsave cd funcsave check_directory_for_new_repository ``` -By [**@mataha**](https://github.com/mataha) +#### 3. CMD + +> By [**@mataha**](https://github.com/mataha) An adaptation of the above snippet suited for Windows's `cmd.exe`, specifically for inclusion in AutoRun scripts or DOSKEY macrofiles: -```batchfile + +```bat @set LAST_REPOSITORY= @doskey cd = ( ^ @@ -102,7 +118,12 @@ specifically for inclusion in AutoRun scripts or DOSKEY macrofiles: ) ``` -By [**@mbrehin**](https://github.com/mbrehin) +### Git alias + +> By [**@mbrehin**](https://github.com/mbrehin) + +You can also add git alias to run onefetch during your git workflows + ```sh # Add Git alias for onefetch. git config --global alias.project-summary '!which onefetch && onefetch' From 04200ed9daef50324125558aea8dead476a4a3ef Mon Sep 17 00:00:00 2001 From: Kia Raad Date: Tue, 29 Oct 2024 22:05:48 +0330 Subject: [PATCH 2/3] Update getting started Add powershell snippet section --- .github/wiki/Getting-Started.md | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/.github/wiki/Getting-Started.md b/.github/wiki/Getting-Started.md index 1b93a9384..8d5de1315 100644 --- a/.github/wiki/Getting-Started.md +++ b/.github/wiki/Getting-Started.md @@ -118,6 +118,41 @@ specifically for inclusion in AutoRun scripts or DOSKEY macrofiles: ) ``` +#### 4. Powershell + +> By [**@kiapanahi**](https://github.com/kiapanahi) + +An adaptation of the above snippet suited for `Powershell`. Put this script in the `$PROFILE`. + +```pwsh +# git repository greeter +$global:lastRepository = $null + +function Check-DirectoryForNewRepository { + $currentRepository = git rev-parse --show-toplevel 2>$null + if ($currentRepository -and ($currentRepository -ne $global:lastRepository)) { + onefetch + } + $global:lastRepository = $currentRepository +} + +function Set-Location { + param ( + [string]$path + ) + + # Use the default Set-Location to change the directory + Microsoft.PowerShell.Management\Set-Location -Path $path + + # Check if we are in a new Git repository + Check-DirectoryForNewRepository +} + +# Optional: Check the repository also when opening a shell directly in a repository directory +# Uncomment the following line if desired +#Check-DirectoryForNewRepository +``` + ### Git alias > By [**@mbrehin**](https://github.com/mbrehin) From a6db90468f17b965171dd71578a453e0c6c85595 Mon Sep 17 00:00:00 2001 From: Kia Raad Date: Tue, 29 Oct 2024 23:06:04 +0330 Subject: [PATCH 3/3] Update getting started document Remove quoted contributions and covert them into simple references --- .github/wiki/Getting-Started.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/wiki/Getting-Started.md b/.github/wiki/Getting-Started.md index 8d5de1315..6530463c4 100644 --- a/.github/wiki/Getting-Started.md +++ b/.github/wiki/Getting-Started.md @@ -28,7 +28,7 @@ If you want to automate the detection and running of `onefetch` every time you ` #### 1. Bash / Zsh -> By [**@quazar-omega**](https://github.com/quazar-omega) +By [**@quazar-omega**](https://github.com/quazar-omega) A script to put in your `.bashrc` - or `.zshrc` - to run onefetch whenever you open a shell into a repository or `cd` into a repository, making sure that it's different from the last one you were in: @@ -56,7 +56,7 @@ check_directory_for_new_repository #### 2. Fish -> By [**@TheSast**](https://github.com/TheSast) +By [**@TheSast**](https://github.com/TheSast) A fish adaptation of the previous script, run it once in your shell to save it: @@ -81,7 +81,7 @@ funcsave check_directory_for_new_repository #### 3. CMD -> By [**@mataha**](https://github.com/mataha) +By [**@mataha**](https://github.com/mataha) An adaptation of the above snippet suited for Windows's `cmd.exe`, specifically for inclusion in AutoRun scripts or DOSKEY macrofiles: @@ -120,7 +120,7 @@ specifically for inclusion in AutoRun scripts or DOSKEY macrofiles: #### 4. Powershell -> By [**@kiapanahi**](https://github.com/kiapanahi) +By [**@kiapanahi**](https://github.com/kiapanahi) An adaptation of the above snippet suited for `Powershell`. Put this script in the `$PROFILE`. @@ -155,7 +155,7 @@ function Set-Location { ### Git alias -> By [**@mbrehin**](https://github.com/mbrehin) +By [**@mbrehin**](https://github.com/mbrehin) You can also add git alias to run onefetch during your git workflows