initial commit

This commit is contained in:
2024-11-17 23:46:59 +01:00
parent abc3f81791
commit e45dbad2b0
4 changed files with 46 additions and 0 deletions
+7
View File
@@ -0,0 +1,7 @@
[package]
name = "navigate"
version = "0.1.0"
edition = "2021"
[dependencies]
clap = { version = "4.5.0", features = ["derive"] }
+3
View File
@@ -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`.
+16
View File
@@ -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 $*)"
}
+20
View File
@@ -0,0 +1,20 @@
use std::env;
fn main()
{
let mut args : Vec<String> = 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)
}
}
}