diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..9ffbe91 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "navigate" +version = "0.1.0" +edition = "2021" + +[dependencies] +clap = { version = "4.5.0", features = ["derive"] } diff --git a/README.md b/README.md new file mode 100644 index 0000000..9694061 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# navigate + +This repository implements a custom shell command for changing directories. It should solve some issues I have with `cd` and `pushd`. diff --git a/bash_setup.sh b/bash_setup.sh new file mode 100644 index 0000000..abf5811 --- /dev/null +++ b/bash_setup.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +export PATH="$PATH:$PWD/target/debug/" +pid=( $(ps -o ppid) ) + +nav() { + cd "$(navigate ${pid[-2]} $*)" +} + +push() { + cd "$(navigate ${pid[-2]} push $*)" +} + +pop() { + cd "$(navigate ${pid[-2]} pop $*)" +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..202fc14 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,20 @@ +use std::env; + + +fn main() +{ + let mut args : Vec = env::args().collect(); + let pid : i32 = args[1].parse().unwrap(); + + // remove arguments which don't require parsing + args.remove(0); // remove command name + args.remove(0); // remove pid + + for arg in args + { + if !(arg.clone().chars().nth(0).unwrap() == '-') + { + println!("{}", arg) + } + } +}