Skip to content

Commit

Permalink
Prepare 12.1.0
Browse files Browse the repository at this point in the history
- Transform river-dreams into a single executable that you can interact with
  using the command-line.
- Add support for PowerShell running on Linux and MacOS.
- On MacOS, directory entries marked with the UF_HIDDEN attribute will now also
  be counted as hidden entries in the right prompt directory stat module.
  • Loading branch information
skippyr committed Oct 14, 2024
1 parent d1042c2 commit 1c6c3fa
Show file tree
Hide file tree
Showing 13 changed files with 1,313 additions and 877 deletions.
7 changes: 7 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AlwaysBreakTemplateDeclarations: true
BasedOnStyle: LLVM
BreakAfterJavaFieldAnnotations: true
FixNamespaceComments: false
JavaScriptQuotes: Single
SpacesInContainerLiterals: false
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
*.swp
.DS_Store
.idea
.vs
.vscode
build
cmake-build-*
out
14 changes: 5 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
cmake_minimum_required(VERSION 3.20)
project(river-dreams)
add_subdirectory("${CMAKE_SOURCE_DIR}/libs/libtmk" "${CMAKE_BINARY_DIR}/libtmk")
add_executable(left-prompt "${CMAKE_SOURCE_DIR}/src/left-prompt.c"
"${CMAKE_SOURCE_DIR}/src/left-prompt.h")
add_executable(right-prompt "${CMAKE_SOURCE_DIR}/src/right-prompt.c"
"${CMAKE_SOURCE_DIR}/src/right-prompt.h")
target_link_libraries(left-prompt tmk)
add_executable(river-dreams "${CMAKE_SOURCE_DIR}/src/river-dreams.c")
target_link_libraries(river-dreams tmk)
if(APPLE)
target_link_libraries(left-prompt "-framework IOKit"
"-framework CoreFoundation")
target_link_libraries(river-dreams "-framework IOKit"
"-framework CoreFoundation")
endif()
target_link_libraries(right-prompt tmk)
install(TARGETS left-prompt right-prompt
install(TARGETS river-dreams
DESTINATION "${CMAKE_SOURCE_DIR}/build/bin")
56 changes: 39 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,23 @@
</p>

## ❡ About
A fast and full-featured tribal looking shell theme available for Windows (PowerShell), Linux (ZSH) and MacOS (ZSH). It is designed to help you develop even your most ambitious software projects.

A fast and full-featured tribal looking shell theme available for PowerShell and ZSH running on Windows, Linux and MacOS.

<p align="center">
<img alt="" src="assets/preview.png" width=1020 />
</p>
<p align="center"><strong>Caption:</strong> River Dreams running on MacOS (ZSH). Terminal theme is <a href="https://github.com/skippyr/flamerial">Flamerial</a>. Font is Hack (patched by the <a href="https://www.nerdfonts.com/font-downloads">Nerd Fonts project</a>).</p>
<p align="center"><strong>Caption:</strong> River Dreams running on MacOS (ZSH). Terminal theme is <a href="https://github.com/skippyr/river-dreams">river-dreams</a>. Font is Hack (patched by the <a href="https://www.nerdfonts.com/font-downloads">Nerd Fonts project</a>).</p>

> [!NOTE]
> The font and colors used in the software may be affected by your terminal settings. Images for illustration purpose only.
### Features

These are the descriptions of each prompt feature from left to right, top to bottom, respectively:

#### Left Prompt Features

- Your local IPV4 address or "No Address" if no address can be found.
- If you are using a laptop, its battery charge and if it is being currently charged.
- Your disk usage.
Expand All @@ -36,17 +39,20 @@ These are the descriptions of each prompt feature from left to right, top to bot
- The exit code of the last command ran.
- The active Python virtual environment, if you have sourced one.
- The current active directory path, shorting it when inside of a Git repository.
- The active branch, when inside of a Git repository.
- When inside of a Git repository, the active branch name or the reference hash if its under rebase.

#### Right Prompt Features

- The total of each entry type in the current active directory: block devices, character devices, directories, fifos, files, hidden entries, sockets, symlinks and temporary entries. Symlinks are followed. Types availability and interpretation are subject to the operating system you are using.

## ❡ Install

### Dependencies

The following dependencies must be installed before it:

#### Dependencies For Windows

- **[Visual Studio 2022](https://visualstudio.microsoft.com) with the "Desktop development with C++" workload:** it provides all the tools required to build this software.
- **[Git](https://git-scm.com):** it will be used to clone this repository.
- **A font patched by the [Nerd Fonts project](https://www.nerdfonts.com/font-downloads):** it provides the pretty symbols used by the software.
Expand All @@ -55,6 +61,7 @@ The following dependencies must be installed before it:
> It is highly recommended that you use a terminal with great Unicode and wide-character support for the symbols used in the theme to appear correctly. Recommendation for Windows is **Windows Terminal**. It comes pre-installed on Windows 11, while on Windows 10 you can download it from the Microsoft Store.
#### Dependencies For Linux

- **GCC, CMake**: they will be used to build this software.
- **Git**: it will be used to clone this repository.
- **A font patched by the [Nerd Fonts project](https://www.nerdfonts.com/font-downloads):** it provides the pretty symbols used by the software.
Expand All @@ -66,6 +73,7 @@ The following dependencies must be installed before it:
> It is highly recommended that you use a terminal with great Unicode and wide-character support for the symbols used in the theme to appear correctly. Recommendation for Linux is **Kitty**. You can download it by following the previous tip.
#### Dependencies For MacOS

- **Apple Command Line Tools, cmake**: they will be used to build this software.
- **Git**: it will be used to clone this repository.
- **A font patched by the [Nerd Fonts project](https://www.nerdfonts.com/font-downloads):** it provides the pretty symbols used by the software.
Expand All @@ -77,59 +85,73 @@ The following dependencies must be installed before it:
> It is highly recommended that you use a terminal with great Unicode and wide-character support for the symbols used in the theme to appear correctly. Recommendation for MacOS is **Kitty**. You can download it by following the previous tip.
### Procedures
#### Procedures For Windows
- Open PowerShell with administrator priveleges.
- Set your PowerShell execution policy to `Bypass`. When prompted, type `y` to accept the changes. This will allow you to execute River Dreams, as, by default, Windows does not allow the execution of any script or configuration file. For more information, access the [PowerShell Execution Policy](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy) documentation page:
#### Procedures For PowerShell

- If you are using Windows, open PowerShell with administrator privileges and set your PowerShell execution policy to `Unrestricted`. When prompted, type `y` to accept the changes. For non-Windows systems this is already the default option. For more information, access the [PowerShell Execution Policy](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy) documentation page:

```ps1
Set-ExecutionPolicy Bypass;
Set-ExecutionPolicy Unrestricted;
```

- Reopen PowerShell without administrator priveleges.
- Open/Reopen PowerShell without administrator privileges.
- Clone this repository using `git`:

```ps1
# For Linux/MacOS
git clone --depth 1 https://github.com/skippyr/river-dreams `
"${env:USERPROFILE}\powershell\themes\river-dreams";
"${env:HOME}/.config/powershell/themes/river-dreams";
# For Windows
git clone --depth 1 https://github.com/skippyr/river-dreams `
"${env:USERPROFILE}\Documents\WindowsPowerShell\themes\river-dreams";
```

- Add the specific connector to the PowerShell profile file:
- Add the PowerShell connector source command to your profile:

```ps1
Write-Output `n'. "${env:USERPROFILE}\powershell\themes\river-dreams\src\connectors\river-dreams.ps1";' | `
# For Linux/MacOS
Write-Output `n'. "${env:HOME}/.config/powershell/themes/river-dreams/src/connectors/river-dreams.ps1";' | `
Out-File -Append -Encoding UTF8 ${PROFILE};
# For Windows
Write-Output `n'. "${env:USERPROFILE}\Documents\WindowsPowerShell\themes\river-dreams\src\connectors\river-dreams.ps1";' | `
Out-File -Append -Encoding UTF8 ${PROFILE};
```

- Reopen PowerShell in order to initiate the theme.
- During its first execution, River Dreams will automatically check its dependencies and build its source code, a process that can take a moment. Once that is done, the theme will be loaded and will be ready for you to use.

#### Procedures For Linux and MacOS
#### Procedures For ZSH

- Open ZSH.
- Clone this repository using `git`:

```zsh
git clone --depth 1 https://github.com/skippyr/river-dreams \
~/.local/share/zsh/themes/river-dreams;
~/.config/zsh/themes/river-dreams;
```

- Add the specific connector to the ZSH profile file:
- Add the ZSH connector source command to your profile:

```zsh
echo "source ~/.local/share/zsh/themes/river-dreams/src/connectors/river-dreams.zsh;" >> ~/.zshrc;
echo "source ~/.config/zsh/themes/river-dreams/src/connectors/river-dreams.zsh;" >> ~/.zshrc;
```

- Reopen ZSH in order to initiate the theme.
- During its first execution, River Dreams will automatically check its dependencies and build its source code, a process that can take a moment. Once that is done, the theme will be loaded and will be ready for you to use.

## ❡ Help
If you need help related to this project, open a new issue in its [issues pages](https://github.com/skippyr/flamerial/issues) or send me an [e-mail](mailto:[email protected]) describing what is going on.

If you need help related to this project, open a new issue in its [issues pages](https://github.com/skippyr/river-dreams/issues) or send me an [e-mail](mailto:[email protected]) describing what is going on.

## ❡ Contributing
This project is open to review and possibly accept contributions, specially fixes and suggestions. If you are interested, send your contribution to its [pull requests page](https://github.com/skippyr/flamerial/pulls) or to my [e-mail](mailto:[email protected]).

This project is open to review and possibly accept contributions, specially fixes and suggestions. If you are interested, send your contribution to its [pull requests page](https://github.com/skippyr/river-dreams/pulls) or to my [e-mail](mailto:[email protected]).

In order to keep it open-source, by contributing to this project, you must agree to license your work under the same license that the project uses. For other intentions, prefer to create a fork.

## ❡ License

This is free software licensed under the MIT License that comes WITH NO WARRANTY. Refer to the `LICENSE` file that comes in its source code for license and copyright details.

&ensp;
Expand Down
2 changes: 1 addition & 1 deletion libs/libtmk
7 changes: 0 additions & 7 deletions src/common.h

This file was deleted.

79 changes: 39 additions & 40 deletions src/connectors/river-dreams.ps1
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
${_riverDreams_root_g} = $(Split-Path $(Split-Path $PSScriptRoot));
${_riverDreams_root_g} = Split-Path $(Split-Path $PSScriptRoot);
${_riverDreams_isWinNt} = [System.Environment]::OsVersion.Platform -match "Win32NT";

${originalPath} = ${env:PATH};
# Visual Studio 2022 Development Profile does not adds CMake to the ${PATH}
# environment variable at the time this script runs. Thus, that need to be
# manually set temporarily.
foreach (${edition} in $(Get-ChildItem "C:\Program Files\Microsoft Visual Studio\2022")) {
# Add each installed edition of Visual Studio 2022 to ${PATH}.
[System.Environment]::SetEnvironmentVariable(
"PATH",
${env:PATH} +
";C:\Program Files\Microsoft Visual Studio\2022\${edition}\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin"
);
}

if (-not(Get-Command git -ErrorAction SilentlyContinue) -or
-not(Get-Command cmake -ErrorAction SilentlyContinue)) {
Write-Host;
Write-Host -ForegroundColor DarkRed -NoNewline "[ERROR] ";
Write-Host -NoNewline "river-dreams ";
Write-Host -ForegroundColor DarkGray -NoNewline "(code 1)"
Write-Host ": some dependecies are missing. Install the ones defined in the README.md file.";
[System.Environment]::SetEnvironmentVariable("PATH", ${originalPath});
${originalPath} = ${null};
return;
}

if (-not (Test-Path "${_riverDreams_root_g}\build\bin\left-prompt.exe") -or
-not (Test-Path "${_riverDreams_root_g}\build\bin\right-prompt.exe")) {
if (-not(Test-Path ("${_riverDreams_root_g}\build\bin\river-dreams" + $(if (${_riverDreams_isWinNt}) { ".exe" })))) {
if (${_riverDreams_isWinNt}) {
${originalPath} = ${env:PATH};
foreach (${year} in $(Get-ChildItem "C:\Program Files\Microsoft Visual Studio")) {
foreach (${edition} in $(Get-ChildItem "C:\Program Files\Microsoft Visual Studio\${year}")) {
[System.Environment]::SetEnvironmentVariable("PATH",
${env:PATH} +
";C:\Program Files\Microsoft Visual Studio\${year}\${edition}\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin");
}
}
}
if (-not(Get-Command git -ErrorAction SilentlyContinue) -or
-not(Get-Command cmake -ErrorAction SilentlyContinue)) {
Write-Host;
Write-Host -ForegroundColor DarkRed -NoNewline "[ERROR] ";
Write-Host -NoNewline "river-dreams ";
Write-Host -ForegroundColor DarkGray -NoNewline "(code 1)"
Write-Host ": some dependecies are missing. Install the ones defined in the README.md file.";
if (${_riverDreams_isWinNt}) {
[System.Environment]::SetEnvironmentVariable("PATH", ${originalPath});
${originalPath} = ${null};
}
return;
}
Write-Host;
Write-Host -ForegroundColor DarkBlue -NoNewline "[INFO] ";
Write-Host "river-dreams: wait while the theme is being prepared for the first time.";
Expand All @@ -39,24 +37,25 @@ if (-not (Test-Path "${_riverDreams_root_g}\build\bin\left-prompt.exe") -or
cmake --build "${_riverDreams_root_g}\build\cmake" --config release > ${null};
cmake --install "${_riverDreams_root_g}\build\cmake" > ${null};
cls;
if (${_riverDreams_isWinNt}) {
[System.Environment]::SetEnvironmentVariable("PATH", ${originalPath});
${originalPath} = ${null};
}
}

[System.Environment]::SetEnvironmentVariable("PATH", ${originalPath});
${originalPath} = ${null};
Set-Item -Path env:VIRTUAL_ENV_DISABLE_PROMPT -Value 1;
[System.Environment]::SetEnvironmentVariable("PATH",
[System.Environment]::GetEnvironmentVariable("PATH") +
$(if (${_riverDreams_isWinNt}) { ";" } else { ":" }) +
(Join-Path (Join-Path ${_riverDreams_root_g} "build") "bin"));

function Prompt {
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8;
${leftPrompt} =
& "${_riverDreams_root_g}\build\bin\left-prompt.exe" `
$([Console]::WindowWidth) `
$(if (${LASTEXITCODE} -eq ${null}) { 0 } else { ${LASTEXITCODE} }) `
$(if (([Security.Principal.WindowsPrincipal] `
[Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) `
{ 1 } else { 0 });
${rightPromptParts} =
& "${_riverDreams_root_g}\build\bin\right-prompt.exe" -Split "`n";
${exitCode} = $(if (${LASTEXITCODE} -eq ${null}) { 0 } else { ${LASTEXITCODE} });
${consoleWidth} = $([Console]::WindowWidth);
${leftPrompt} = & "river-dreams" "pwsh" "left" ${exitCode} ${consoleWidth};
Write-Host -NoNewline ${leftPrompt};
${rightPromptParts} =
& "river-dreams" "pwsh" "right" ${exitCode} ${consoleWidth} -Split "`n";
if (${rightPromptParts}[1] -gt 0) {
${cursorLeft} = [Console]::CursorLeft;
${cursorTop} = [Console]::CursorTop;
Expand Down
24 changes: 13 additions & 11 deletions src/connectors/river-dreams.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ setopt promptsubst;
export VIRTUAL_ENV_DISABLE_PROMPT=1;
_riverDreams_root_g=$(dirname $(dirname $(dirname ${0})));

if [[ ! $(command -v git) || ! $(command -v cmake) || ! $(command -v gcc) ||
! $(command -v make) ]]; then
echo;
echo "\x1b[31m[ERROR] \x1b[1;39mriver-dreams \x1b[22;38;5;8m(code 1)\x1b[39m: some dependencies are missing. Install the ones defined in README.md file.";
return;
fi

if [[ ! -f "${_riverDreams_root_g}/build/bin/left-prompt" ||
! -f "${_riverDreams_root_g}/build/bin/right-prompt" ]]; then
if [[ ! -f "${_riverDreams_root_g}/build/bin/river-dreams" ]];
then
if [[ ! $(command -v git) || ! $(command -v cmake) || ! $(command -v gcc) ||
! $(command -v make) ]];
then
echo;
echo "\x1b[31m[ERROR] \x1b[1;39mriver-dreams \x1b[22;38;5;8m(code 1)\x1b[39m: some dependencies are missing. Install the ones defined in README.md file.";
return;
fi
echo;
echo "\x1b[34m[INFO] \x1b[1;39mriver-dreams\x1b[22m: wait while the theme is being prepared for the first time.";
git -C ${_riverDreams_root_g} submodule init &> /dev/null;
Expand All @@ -24,5 +24,7 @@ if [[ ! -f "${_riverDreams_root_g}/build/bin/left-prompt" ||
clear;
fi

PROMPT='$(${_riverDreams_root_g}/build/bin/left-prompt)';
RPROMPT='$(${_riverDreams_root_g}/build/bin/right-prompt)';
export PATH="${PATH}:${_riverDreams_root_g}/build/bin";

PROMPT='$(river-dreams zsh left)';
RPROMPT='$(river-dreams zsh right)';
Loading

0 comments on commit 1c6c3fa

Please sign in to comment.