diff --git a/.github/workflows/bashisms.yml b/.github/workflows/bashisms.yml index 7226bb5c..7ce39ef1 100644 --- a/.github/workflows/bashisms.yml +++ b/.github/workflows/bashisms.yml @@ -19,17 +19,27 @@ jobs: id: get_sh_files run: | sh_files=$(git diff --name-only origin/${{ github.base_ref }} HEAD core/tabs | grep '\.sh$' || true) - echo "::set-output name=sh_files::$sh_files" + if [ -n "$sh_files" ]; then + echo "$sh_files" > changed_files + echo "changed=1" >> $GITHUB_OUTPUT + else + echo "changed=0" >> $GITHUB_OUTPUT + fi - name: Install devscripts - if: steps.get_sh_files.outputs.sh_files != '' + if: steps.get_sh_files.outputs.changed == 1 run: sudo apt-get update && sudo apt-get install devscripts - name: Check for bashisms - if: steps.get_sh_files.outputs.sh_files != '' + if: steps.get_sh_files.outputs.changed == 1 run: | - for file in ${{ steps.get_sh_files.outputs.sh_files }}; do - if [[ -f "$file" ]]; then - checkbashisms "$file" - fi + echo "Running for:\n$(cat changed_files)\n" + for file in $(cat changed_files); do + if [[ -f "$file" ]]; then + checkbashisms "$file" + fi done + + - name: Remove the created file + if: steps.get_sh_files.outputs.changed == 1 + run: rm changed_files diff --git a/.github/workflows/linutil.yml b/.github/workflows/linutil.yml index f57e8a74..e6d464da 100644 --- a/.github/workflows/linutil.yml +++ b/.github/workflows/linutil.yml @@ -88,3 +88,23 @@ jobs: env: version: ${{ env.version }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Install vhs + run: | + wget 'https://github.com/charmbracelet/vhs/releases/download/v0.8.0/vhs_0.8.0_amd64.deb' + sudo apt install -y ffmpeg + sudo snap install ttyd --classic + sudo dpkg -i 'vhs_0.8.0_amd64.deb' + + - name: Build the preview + run: | + export PATH="$(pwd)/build:$PATH" + vhs docs/assets/preview.tape -o docs/assets/preview.gif + + - name: Upload the preview + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: Preview for ${{ env.version }} + file_pattern: "docs/assets/preview.gif" + add_options: "--force" + if: success() diff --git a/Cargo.lock b/Cargo.lock index 1ff46393..81750251 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -328,12 +328,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - [[package]] name = "getrandom" version = "0.2.15" @@ -491,19 +485,19 @@ checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" [[package]] name = "linutil_core" -version = "24.9.23" +version = "24.9.28" dependencies = [ "ego-tree", "include_dir", "serde", - "tempdir", + "temp-dir", "toml", "which", ] [[package]] name = "linutil_tui" -version = "24.9.23" +version = "24.9.28" dependencies = [ "ansi-to-tui", "anstyle", @@ -514,8 +508,9 @@ dependencies = [ "linutil_core", "oneshot", "portable-pty", - "rand 0.8.5", + "rand", "ratatui", + "temp-dir", "tree-sitter-bash", "tree-sitter-highlight", "tui-term", @@ -716,19 +711,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" -dependencies = [ - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "rdrand", - "winapi", -] - [[package]] name = "rand" version = "0.8.5" @@ -737,7 +719,7 @@ checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha", - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -747,24 +729,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.4", + "rand_core", ] -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - [[package]] name = "rand_core" version = "0.6.4" @@ -795,15 +762,6 @@ dependencies = [ "unicode-width 0.1.14", ] -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "redox_syscall" version = "0.5.4" @@ -842,15 +800,6 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] - [[package]] name = "rustix" version = "0.38.37" @@ -1063,14 +1012,10 @@ dependencies = [ ] [[package]] -name = "tempdir" -version = "0.3.7" +name = "temp-dir" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" -dependencies = [ - "rand 0.4.6", - "remove_dir_all", -] +checksum = "bc1ee6eef34f12f765cb94725905c6312b6610ab2b0940889cfe58dae7bc3c72" [[package]] name = "termios" @@ -1235,8 +1180,7 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "vt100" version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84cd863bf0db7e392ba3bd04994be3473491b31e66340672af5d11943c6274de" +source = "git+https://github.com/ChrisTitusTech/vt100-rust#e41fb3d8fb5fd01dd2d076c9a25823a31656012f" dependencies = [ "itoa", "log", diff --git a/Cargo.toml b/Cargo.toml index 27257d9c..cf43a012 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,9 @@ ego-tree = "0.6.2" members = ["tui", "core"] resolver = "2" +[patch.crates-io] +vt100 = { git = "https://github.com/ChrisTitusTech/vt100-rust" } + [profile.release] opt-level = "z" debug = false diff --git a/README.md b/README.md index b2f33406..3c03bd87 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![Crates.io Version](https://img.shields.io/crates/v/linutil_tui?style=for-the-badge&color=%23af3a03)](https://crates.io/crates/linutil_tui) [![linutil AUR Version](https://img.shields.io/aur/version/linutil?style=for-the-badge&label=%5BAUR%5D%20linutil&color=%23230567ff)](https://aur.archlinux.org/packages/linutil) [![linutil-bin AUR Version](https://img.shields.io/aur/version/linutil-bin?style=for-the-badge&label=%5BAUR%5D%20linutil-bin&color=%23230567ff)](https://aur.archlinux.org/packages/linutil-bin) -![Preview](docs/assets/preview.png) +![Preview](docs/assets/preview.gif) **Linutil** is a distro-agnostic toolbox designed to simplify everyday Linux tasks. It helps you set up applications and optimize your system for specific use cases. The utility is actively developed in Rust 🦀, providing performance and reliability. diff --git a/cargo-lock-merge.txt b/cargo-lock-merge.txt deleted file mode 100644 index 649a99cf..00000000 --- a/cargo-lock-merge.txt +++ /dev/null @@ -1,5 +0,0 @@ -What to do when you have a Cargo.lock merge conflict? -1. `git checkout origin/main -- Cargo.lock` to get the original Cargo.lock -2. `cargo build` to update Cargo.lock -3. `git add Cargo.lock` -4. continue the merge as normal \ No newline at end of file diff --git a/core/Cargo.toml b/core/Cargo.toml index 8605c94c..d3f42011 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -13,7 +13,7 @@ include = [ [dependencies] include_dir = "0.7.4" -tempdir = "0.3.7" +temp-dir = "0.1.14" serde = { version = "1.0.205", features = ["derive"], default-features = false } toml = { version = "0.8.19", features = ["parse"], default-features = false } which = "6.0.3" diff --git a/core/src/inner.rs b/core/src/inner.rs index 96ffc634..ed810b06 100644 --- a/core/src/inner.rs +++ b/core/src/inner.rs @@ -10,24 +10,29 @@ use crate::{Command, ListNode, Tab}; use ego_tree::{NodeMut, Tree}; use include_dir::{include_dir, Dir}; use serde::Deserialize; -use tempdir::TempDir; +use temp_dir::TempDir; const TAB_DATA: Dir = include_dir!("$CARGO_MANIFEST_DIR/tabs"); -pub fn get_tabs(validate: bool) -> Vec { - let tab_files = TabList::get_tabs(); - let tabs = tab_files.into_iter().map(|path| { - let directory = path.parent().unwrap().to_owned(); - let data = std::fs::read_to_string(path).expect("Failed to read tab data"); - let mut tab_data: TabEntry = toml::from_str(&data).expect("Failed to parse tab data"); +pub fn get_tabs(validate: bool) -> (TempDir, Vec) { + let (temp_dir, tab_files) = TabList::get_tabs(); - if validate { - filter_entries(&mut tab_data.data); - } - (tab_data, directory) - }); + let tabs: Vec<_> = tab_files + .into_iter() + .map(|path| { + let directory = path.parent().unwrap().to_owned(); + let data = std::fs::read_to_string(path).expect("Failed to read tab data"); + let mut tab_data: TabEntry = toml::from_str(&data).expect("Failed to parse tab data"); + + if validate { + filter_entries(&mut tab_data.data); + } + (tab_data, directory) + }) + .collect(); let tabs: Vec = tabs + .into_iter() .map(|(TabEntry { name, data }, directory)| { let mut tree = Tree::new(Rc::new(ListNode { name: "root".to_string(), @@ -45,7 +50,7 @@ pub fn get_tabs(validate: bool) -> Vec { if tabs.is_empty() { panic!("No tabs found"); } - tabs + (temp_dir, tabs) } #[derive(Deserialize)] @@ -242,19 +247,20 @@ fn is_executable(path: &Path) -> bool { } impl TabList { - fn get_tabs() -> Vec { - let temp_dir = TempDir::new("linutil_scripts").unwrap().into_path(); + fn get_tabs() -> (TempDir, Vec) { + let temp_dir = TempDir::new().unwrap(); TAB_DATA .extract(&temp_dir) .expect("Failed to extract the saved directory"); - let tab_files = - std::fs::read_to_string(temp_dir.join("tabs.toml")).expect("Failed to read tabs.toml"); + let tab_files = std::fs::read_to_string(temp_dir.path().join("tabs.toml")) + .expect("Failed to read tabs.toml"); let data: Self = toml::from_str(&tab_files).expect("Failed to parse tabs.toml"); - - data.directories + let tab_paths = data + .directories .iter() - .map(|path| temp_dir.join(path).join("tab_data.toml")) - .collect() + .map(|path| temp_dir.path().join(path).join("tab_data.toml")) + .collect(); + (temp_dir, tab_paths) } } diff --git a/docs/assets/preview.gif b/docs/assets/preview.gif new file mode 100644 index 00000000..c8e49da1 Binary files /dev/null and b/docs/assets/preview.gif differ diff --git a/docs/assets/preview.png b/docs/assets/preview.png deleted file mode 100644 index bb8b7037..00000000 Binary files a/docs/assets/preview.png and /dev/null differ diff --git a/docs/assets/preview.tape b/docs/assets/preview.tape new file mode 100644 index 00000000..ca2b59d7 --- /dev/null +++ b/docs/assets/preview.tape @@ -0,0 +1,88 @@ +# VHS documentation +# +# Output: +# Output .gif Create a GIF output at the given +# Output .mp4 Create an MP4 output at the given +# Output .webm Create a WebM output at the given +# +# Require: +# Require Ensure a program is on the $PATH to proceed +# +# Settings: +# Set FontSize Set the font size of the terminal +# Set FontFamily Set the font family of the terminal +# Set Height Set the height of the terminal +# Set Width Set the width of the terminal +# Set LetterSpacing Set the font letter spacing (tracking) +# Set LineHeight Set the font line height +# Set LoopOffset % Set the starting frame offset for the GIF loop +# Set Theme Set the theme of the terminal +# Set Padding Set the padding of the terminal +# Set Framerate Set the framerate of the recording +# Set PlaybackSpeed Set the playback speed of the recording +# Set MarginFill Set the file or color the margin will be filled with. +# Set Margin Set the size of the margin. Has no effect if MarginFill isn't set. +# Set BorderRadius Set terminal border radius, in pixels. +# Set WindowBar Set window bar type. (one of: Rings, RingsRight, Colorful, ColorfulRight) +# Set WindowBarSize Set window bar size, in pixels. Default is 40. +# Set TypingSpeed