Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvements to some of the default cable channels #323

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ toggle_preview = "ctrl-o"
# docker-images channel
"docker run" = "docker-images"

# podman-images channel
"podman run" = "podman-images"

# gitrepos channel
"nvim" = "git-repos"

Expand Down
56 changes: 56 additions & 0 deletions cable/macos-channels.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# GIT
[[cable_channel]]
name = "git-diff"
source_command = "git diff --name-only"
preview_command = "git diff --color=always {0}"

[[cable_channel]]
name = "git-reflog"
source_command = 'git reflog'
preview_command = 'git show -p --stat --pretty=fuller --color=always {0}'

[[cable_channel]]
name = "git-log"
source_command = "git log --oneline --date=short --pretty=\"format:%h %s %an %cd\" \"$@\""
preview_command = "git show -p --stat --pretty=fuller --color=always {0}"

[[cable_channel]]
name = "git-branch"
source_command = "git --no-pager branch --all --format=\"%(refname:short)\""
preview_command = "git show -p --stat --pretty=fuller --color=always {0}"

# Docker
[[cable_channel]]
name = "docker-images"
source_command = "docker image list --format=json | jq -r '.[] | .Names[0] // .Id'"
preview_command = "docker image inspect {0} | jq -C"

[[cable_channel]]
name = "podman-images"
source_command = "podman image list --format=json | jq -r '.[] | .Names[0] // .Id'"
preview_command = "podman image inspect {0} | jq -C"

# S3
[[cable_channel]]
name = "s3-buckets"
source_command = "aws s3 ls | cut -d \" \" -f 3"
preview_command = "aws s3 ls s3://{0}"

# Dotfiles
[[cable_channel]]
name = "my-dotfiles"
source_command = "fd -t f . $HOME/.config"
preview_command = ":files:"

# Shell history
[[cable_channel]]
name = "zsh-history"
source_command = "tail -r $HOME/.zsh_history | cut -d\";\" -f 2-"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, doing a drive by comment here, but I'd consider using the the zsh $HISTFILE parameter here. It's up to the user to set. It's only convention that ~/.zsh_history is typically used. Maybe use it as a fallback? ${HISTFILE:-${HOME}/.zsh_history}

Same thing for bash as well with its HISTFILE variable.


[[cable_channel]]
name = "bash-history"
source_command = "tail -r $HOME/.bash_history"

[[cable_channel]]
name = "fish-history"
source_command = "fish -c 'history'"
11 changes: 8 additions & 3 deletions cable/unix-channels.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ preview_command = "git show -p --stat --pretty=fuller --color=always {0}"
# Docker
[[cable_channel]]
name = "docker-images"
source_command = "docker image list --format \"{{.ID}}\""
source_command = "docker image list --format=json | jq -r '.[] | .Names[0] // .Id'"
preview_command = "docker image inspect {0} | jq -C"

[[cable_channel]]
name = "podman-images"
source_command = "podman image list --format=json | jq -r '.[] | .Names[0] // .Id'"
preview_command = "podman image inspect {0} | jq -C"

# S3
[[cable_channel]]
name = "s3-buckets"
Expand All @@ -40,11 +45,11 @@ preview_command = ":files:"
# Shell history
[[cable_channel]]
name = "zsh-history"
source_command = "sed '1!G;h;$!d' $HOME/.zsh_history | cut -d\";\" -f 2-"
source_command = "tac $HOME/.zsh_history | cut -d\";\" -f 2-"

[[cable_channel]]
name = "bash-history"
source_command = "sed '1!G;h;$!d' $HOME/.bash_history"
source_command = "tac $HOME/.bash_history"

[[cable_channel]]
name = "fish-history"
Expand Down
8 changes: 6 additions & 2 deletions television/cable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ struct ChannelPrototypes {
const CABLE_FILE_NAME_SUFFIX: &str = "channels";
const CABLE_FILE_FORMAT: &str = "toml";

#[cfg(unix)]
#[cfg(target_os = "macos")]
const DEFAULT_CABLE_CHANNELS: &str =
include_str!("../cable/macos-channels.toml");

#[cfg(all(unix, not(target_os = "macos")))]
const DEFAULT_CABLE_CHANNELS: &str =
include_str!("../cable/unix-channels.toml");

#[cfg(not(unix))]
#[cfg(windows)]
const DEFAULT_CABLE_CHANNELS: &str =
include_str!("../cable/windows-channels.toml");

Expand Down