initial commit
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
[package]
|
||||||
|
name = "navigate"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
clap = { version = "4.5.0", features = ["derive"] }
|
||||||
@@ -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`.
|
||||||
@@ -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
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user