shell/zsh: add fzf preview
This commit is contained in:
parent
f7c3d2c040
commit
96a80f9b35
3 changed files with 15 additions and 10 deletions
10
shell/zsh
10
shell/zsh
|
@ -1,5 +1,5 @@
|
||||||
function __tas_task_idx() {
|
function __tas_task_idx() {
|
||||||
echo "$@" | sed 's/^\([0-9]\+\)\..\+$/\1/'
|
echo "$@" | sed 's/^[> ] \([0-9]\+\)\..\+$/\1/'
|
||||||
}
|
}
|
||||||
|
|
||||||
function __tas_show() {
|
function __tas_show() {
|
||||||
|
@ -11,13 +11,15 @@ function __tas_start() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function __tas_list() {
|
function __tas_list() {
|
||||||
tas list | fzf --info=inline --height=50% --no-sort --keep-right --layout=reverse
|
tas list | fzf \
|
||||||
|
--info=inline --height=50% --no-sort --keep-right --layout=reverse \
|
||||||
|
--preview="tas show \$(sed 's/^[> ] \\([0-9]\\+\\)\\..\\+$/\\1/' {+f})"
|
||||||
}
|
}
|
||||||
|
|
||||||
function taz() {
|
function taz() {
|
||||||
case $1 in
|
case $1 in
|
||||||
"" | "show" | "sh")
|
"" | "show" | "sh")
|
||||||
__tas_show $(__tas_list)
|
__tas_show "$(__tas_list)"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"list" | "ls")
|
"list" | "ls")
|
||||||
|
@ -25,7 +27,7 @@ function taz() {
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"start" | "st")
|
"start" | "st")
|
||||||
__tas_start $(__tas_list)
|
__tas_start "$(__tas_list)"
|
||||||
|
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
10
src/cli.rs
10
src/cli.rs
|
@ -51,17 +51,21 @@ pub enum SubCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_task_detail(task: &domain::Task) {
|
pub fn print_task_detail(task: &domain::Task) {
|
||||||
print!(" ");
|
print_task_detail_opt(task, " ")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn print_task_detail_opt(task: &domain::Task, prefix: &str) {
|
||||||
|
print!("{prefix}");
|
||||||
if let Some(project) = task.project.as_ref() {
|
if let Some(project) = task.project.as_ref() {
|
||||||
print!("[{}]: ", project);
|
print!("[{}]: ", project);
|
||||||
}
|
}
|
||||||
println!("{}", task.name);
|
println!("{}", task.name);
|
||||||
|
|
||||||
if let Some(link) = task.link.as_ref() {
|
if let Some(link) = task.link.as_ref() {
|
||||||
println!(" link: {}", link);
|
println!("{prefix}link: {}", link);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(dir_path) = task.dir_path.as_ref() {
|
if let Some(dir_path) = task.dir_path.as_ref() {
|
||||||
println!(" path: {}", dir_path.to_string_lossy());
|
println!("{prefix}path: {}", dir_path.to_string_lossy());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::process::{Command, Stdio};
|
use std::process::{Command, Stdio};
|
||||||
|
|
||||||
use crate::cli::print_task_detail;
|
use crate::cli::print_task_detail_opt;
|
||||||
use crate::domain::CurrentTaskInfo;
|
use crate::domain::CurrentTaskInfo;
|
||||||
use crate::repo::Repository;
|
use crate::repo::Repository;
|
||||||
|
|
||||||
|
@ -109,8 +109,7 @@ pub fn execute(repo: impl Repository, args: Args) {
|
||||||
eprintln!("[WARNING]: You don't provide part. --clip option will ignore.");
|
eprintln!("[WARNING]: You don't provide part. --clip option will ignore.");
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("Information about your current task:");
|
print_task_detail_opt(&task, "");
|
||||||
print_task_detail(&task);
|
|
||||||
}
|
}
|
||||||
Some(PrintPart::Project) => {
|
Some(PrintPart::Project) => {
|
||||||
if args.clip {
|
if args.clip {
|
||||||
|
|
Loading…
Reference in a new issue