mirror of
https://github.com/kogakure/dotfiles.git
synced 2026-02-03 20:25:30 +00:00
feat(nix): migrate zsh, starship, zoxide, and fzf
This commit is contained in:
@@ -4,24 +4,6 @@
|
||||
programs.bash = {
|
||||
enable = true;
|
||||
enableCompletion = true;
|
||||
sessionVariables = {
|
||||
SSH_AUTH_SOCK = "$HOME/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh";
|
||||
FD_OPTIONS = "--follow --exclude .git --exclude node_modules";
|
||||
KEYTIMEOUT = 1;
|
||||
GIT_EDITOR = "nvim";
|
||||
EDITOR = "nvim";
|
||||
FZF_DEFAULT_COMMAND = "git ls-files --cached --others --exclude-standard | fd --hidden --type f --type l $FD_OPTIONS";
|
||||
FZF_DEFAULT_OPTS = "--no-height";
|
||||
FZF_CTRL_T_COMMAND = "$FZF_DEFAULT_COMMAND";
|
||||
FZF_CTRL_T_OPTS = "--preview 'bat --color=always --style=numbers {}' --bind shift-up:preview-page-up,shift-down:preview-page-down";
|
||||
FZF_CTRL_R_OPTS = "--reverse";
|
||||
FZF_TMUX_OPTS = "-p";
|
||||
FZF_ALT_C_COMMAND = "fd --type d $FD_OPTIONS --color=never --hidden";
|
||||
FZF_ALT_C_OPTS = "--preview 'tree -C {} | head -50'";
|
||||
};
|
||||
shellAliases = {
|
||||
".." = "cd ..";
|
||||
};
|
||||
shellOptions = [
|
||||
"histappend"
|
||||
"checkwinsize"
|
||||
|
||||
@@ -14,6 +14,7 @@ in
|
||||
./ctags
|
||||
./curl
|
||||
./editorconfig
|
||||
./fzf
|
||||
./gh
|
||||
./gh-dash
|
||||
./git
|
||||
@@ -29,11 +30,14 @@ in
|
||||
./ruby
|
||||
./sesh
|
||||
./skhd
|
||||
./starship
|
||||
./wezterm
|
||||
./wget
|
||||
./yabai
|
||||
./yazi
|
||||
./zed
|
||||
./zoxide
|
||||
./zsh
|
||||
];
|
||||
|
||||
config = {
|
||||
@@ -47,29 +51,52 @@ in
|
||||
&& tic -x -o ~/.terminfo $tempfile \
|
||||
&& rm $tempfile
|
||||
'';
|
||||
# Install custom icon for WezTerm
|
||||
setupWezTermCustomIcon = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||
icon_path="$HOME/.config/wezterm/terminal.icns"
|
||||
app_path="/Applications/WezTerm.app"
|
||||
|
||||
$DRY_RUN_CMD mkdir -p "$(dirname "$icon_path")"
|
||||
$DRY_RUN_CMD cp -f ${./wezterm/wezterm.icns} "$icon_path"
|
||||
|
||||
if [ -d "$app_path" ]; then
|
||||
$DRY_RUN_CMD cp "$icon_path" "$app_path"/Contents/Resources/terminal.icns
|
||||
|
||||
# Touch the app to refresh Finder
|
||||
$DRY_RUN_CMD touch "$app_path"
|
||||
$DRY_RUN_CMD ${pkgs.darwin.xattr}/bin/xattr -rc "$app_path"
|
||||
|
||||
$VERBOSE_ECHO "Applied custom icon to WezTerm.app"
|
||||
$DRY_RUN_CMD touch "$app_path"
|
||||
else
|
||||
$VERBOSE_ECHO "WezTerm.app not found in /Applications. Custom icon not applied."
|
||||
fi
|
||||
'';
|
||||
};
|
||||
|
||||
# Session Variables
|
||||
home.sessionVariables = {
|
||||
KEYTIMEOUT = 1;
|
||||
|
||||
# Man
|
||||
MANPATH = "/usr/local/man:$MANPATH";
|
||||
|
||||
# Editor
|
||||
EDITOR = "nvim";
|
||||
GIT_EDITOR = "nvim";
|
||||
|
||||
# Secretive
|
||||
SSH_AUTH_SOCK = "$HOME/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh";
|
||||
|
||||
# Volta
|
||||
VOLTA_HOME = "$HOME/.volta";
|
||||
};
|
||||
|
||||
# Session Paths
|
||||
home.sessionPath = [
|
||||
# Personal scripts
|
||||
"$HOME/.dotfiles/bin"
|
||||
"$HOME/.dotfiles/private/bin"
|
||||
|
||||
# Homebrew
|
||||
"/opt/homebrew/bin"
|
||||
"/opt/homebrew/sbin"
|
||||
|
||||
# Misc
|
||||
"$HOME/.local/bin"
|
||||
"/usr/local/bin"
|
||||
"/usr/local/sbin"
|
||||
#
|
||||
# Rust
|
||||
"$HOME/.cargo/bin"
|
||||
|
||||
# Tmux plugins
|
||||
"$HOME/.tmux/plugins/tmux-nvr/bin"
|
||||
"$HOME/.tmux/plugins/t-smart-tmux-session-manager/bin"
|
||||
|
||||
# Volta
|
||||
"$VOLTA_HOME/bin"
|
||||
];
|
||||
|
||||
# Let Home Manager install and manage itself.
|
||||
programs.home-manager.enable = true;
|
||||
|
||||
@@ -91,13 +118,13 @@ in
|
||||
coreutils # GNU Core Utilities
|
||||
darwin.xattr # Display and manipulate extended attributes
|
||||
diff-so-fancy # Good-looking diffs filter for git
|
||||
docker # Pack, ship and run any application as a lightweight container
|
||||
docker-buildx # Docker CLI plugin for extended build capabilities with BuildKit
|
||||
dust # du + rust = dust. Like du but more intuitive
|
||||
exiftool # Tool to read, write and edit EXIF meta information
|
||||
eza # Modern, maintained replacement for ls
|
||||
fd # Simple, fast and user-friendly alternative to find
|
||||
ffmpeg_7 # Complete, cross-platform solution to record, convert and stream audio and video
|
||||
fzf # Command-line fuzzy finder written in Go
|
||||
glow # Render markdown on the CLI, with pizzazz!
|
||||
gource # Software version control visualization tool
|
||||
grex # Command-line tool for generating regular expressions from user-provided test cases
|
||||
@@ -131,7 +158,6 @@ in
|
||||
woff2 # Webfont compression reference code
|
||||
yarn # Fast, reliable, and secure dependency management for javascript
|
||||
yt-dlp # Command-line tool to download videos from YouTube.com and other sites (youtube-dl fork)
|
||||
zoxide # Fast cd command that learns your habits
|
||||
|
||||
# Programming Languages
|
||||
lua # Powerful, fast, lightweight, embeddable scripting language
|
||||
|
||||
30
nix/home/fzf/default.nix
Normal file
30
nix/home/fzf/default.nix
Normal file
@@ -0,0 +1,30 @@
|
||||
{ ... }:
|
||||
|
||||
let
|
||||
fdOptions = "--follow --exclude .git --exclude node_modules";
|
||||
in
|
||||
{
|
||||
programs.fzf = {
|
||||
enable = true;
|
||||
enableBashIntegration = true;
|
||||
enableZshIntegration = true;
|
||||
enableFishIntegration = true;
|
||||
|
||||
defaultCommand = "git ls-files --cached --others --exclude-standard | fd --hidden --type f --type l ${fdOptions}";
|
||||
defaultOptions = [ "--no-height" ];
|
||||
|
||||
changeDirWidgetCommand = "fd --type d ${fdOptions} --color=never --hidden";
|
||||
changeDirWidgetOptions = [ "--preview 'tree -C {} | head -50'" ];
|
||||
|
||||
fileWidgetCommand = "git ls-files --cached --others --exclude-standard | fd --hidden --type f --type l ${fdOptions}";
|
||||
fileWidgetOptions = [
|
||||
"--preview 'bat --color=always --style=numbers {}'"
|
||||
"--bind shift-up:preview-page-up,shift-down:preview-page-down"
|
||||
];
|
||||
|
||||
historyWidgetOptions = [ "--reverse" ];
|
||||
|
||||
tmux.enableShellIntegration = true;
|
||||
tmux.shellIntegrationOptions = [ "-p" ];
|
||||
};
|
||||
}
|
||||
27
nix/home/starship/default.nix
Normal file
27
nix/home/starship/default.nix
Normal file
@@ -0,0 +1,27 @@
|
||||
{ ... }:
|
||||
|
||||
{
|
||||
programs.starship = {
|
||||
enable = true;
|
||||
enableBashIntegration = true;
|
||||
enableZshIntegration = true;
|
||||
enableFishIntegration = true;
|
||||
settings = {
|
||||
add_newline = false;
|
||||
command_timeout = 2000;
|
||||
battery = {
|
||||
disabled = true;
|
||||
display = [
|
||||
{
|
||||
threshold = 10;
|
||||
style = "bold red";
|
||||
}
|
||||
{
|
||||
threshold = 30;
|
||||
style = "bold yellow";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
10
nix/home/zoxide/default.nix
Normal file
10
nix/home/zoxide/default.nix
Normal file
@@ -0,0 +1,10 @@
|
||||
{ ... }:
|
||||
|
||||
{
|
||||
programs.zoxide = {
|
||||
enable = true;
|
||||
enableBashIntegration = true;
|
||||
enableZshIntegration = true;
|
||||
enableFishIntegration = true;
|
||||
};
|
||||
}
|
||||
21
nix/home/zsh/_cht
Normal file
21
nix/home/zsh/_cht
Normal file
@@ -0,0 +1,21 @@
|
||||
#compdef cht.sh
|
||||
|
||||
__CHTSH_LANGS=($(curl -s cheat.sh/:list))
|
||||
_arguments -C \
|
||||
'--help[show this help message and exit]: :->noargs' \
|
||||
'--shell[enter shell repl]: :->noargs' \
|
||||
'1:Cheat Sheet:->lang' \
|
||||
'*::: :->noargs' && return 0
|
||||
|
||||
if [[ CURRENT -ge 1 ]]; then
|
||||
case $state in
|
||||
noargs)
|
||||
_message "nothing to complete";;
|
||||
lang)
|
||||
compadd -X "Cheat Sheets" ${__CHTSH_LANGS[@]};;
|
||||
*)
|
||||
_message "Unknown state, error in autocomplete";;
|
||||
esac
|
||||
|
||||
return
|
||||
fi
|
||||
164
nix/home/zsh/default.nix
Normal file
164
nix/home/zsh/default.nix
Normal file
@@ -0,0 +1,164 @@
|
||||
{ lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
chtCompletionScript = pkgs.writeTextFile {
|
||||
name = "_cht";
|
||||
text = builtins.readFile ./_cht;
|
||||
destination = "/share/zsh/site-functions/_cht";
|
||||
};
|
||||
in
|
||||
{
|
||||
programs.zsh = {
|
||||
enable = true;
|
||||
enableCompletion = true;
|
||||
autosuggestion.enable = true;
|
||||
syntaxHighlighting.enable = true;
|
||||
shellAliases = {
|
||||
# ZSH
|
||||
zshconfig = "vim $HOME/.zshrc";
|
||||
reload = "source $HOME/.zshrc";
|
||||
|
||||
# Folders
|
||||
"..." = "cd ../..";
|
||||
".." = "cd ..";
|
||||
"cd.." = "cd ..";
|
||||
ls = "eza --git --group-directories-first --icons";
|
||||
ll = "eza -l --git --group-directories-first --icons";
|
||||
lla = "ll -a";
|
||||
mkdir = "mkdir -p";
|
||||
|
||||
# Git aliases
|
||||
ga = "git add";
|
||||
gb = "git branch";
|
||||
gba = "git branch -a";
|
||||
gc = "git commit -v";
|
||||
gca = "git commit -v -a";
|
||||
gcam = "git commit --amend";
|
||||
gcan = "git commit --amend --no-edit";
|
||||
gd = "git diff -- . ':(exclude)yarn.lock'";
|
||||
gdc = "git diff --cached";
|
||||
gdh = "git diff head";
|
||||
gdt = "git difftool";
|
||||
gfa = "git fetch --all";
|
||||
gg = "git log";
|
||||
ghi = "git hist";
|
||||
gl = "git pull";
|
||||
glr = "git pull --rebase";
|
||||
gp = "git push";
|
||||
gpf = "git push --force-with-lease";
|
||||
gpu = "git push -u origin HEAD";
|
||||
gpv = "git push --no-verify";
|
||||
grb = "git rebase master";
|
||||
grbc = "git rebase --continue";
|
||||
grbi = "git rebase -i ";
|
||||
grbs = "git rebase --skip";
|
||||
gru = "git remote update";
|
||||
gsb = "git show-branch";
|
||||
gsl = "git submodule foreach git pull";
|
||||
gst = "git status -sb";
|
||||
gsu = "git submodule update";
|
||||
gu = "git up";
|
||||
gw = "git whatchanged";
|
||||
gwp = "git whatchanged -p";
|
||||
lg = "lazygit";
|
||||
|
||||
# Vim
|
||||
v = "vim";
|
||||
vim = "nvim";
|
||||
|
||||
# Tmux
|
||||
t = "tmux";
|
||||
tn = "tmux new -s $(pwd | sed 's/.*\///g')";
|
||||
|
||||
# Bat
|
||||
cat = "bat";
|
||||
|
||||
# TLDR
|
||||
tldrf = "tldr --list --single-column | fzf --preview \"tldr --color=always {1}\" --preview-window=right,70% | xargs tldr";
|
||||
|
||||
# iA Writer
|
||||
ia = "open $1 -a /Applications/iA\\ Writer.app";
|
||||
|
||||
# Dotfiles folder
|
||||
dotfiles = "cd $HOME/.dotfiles";
|
||||
|
||||
# iCloud
|
||||
icloud = "cd $HOME/Library/Mobile\\ Documents/com~apple~CloudDocs";
|
||||
|
||||
# Get week number
|
||||
week = "date +%V";
|
||||
|
||||
# Stopwatch
|
||||
timer = "echo \"Timer started. Stop with Ctrl-D.\" && date && time cat && date";
|
||||
|
||||
# IP addresses
|
||||
ip = "dig +short myip.opendns.com @resolver1.opendns.com";
|
||||
|
||||
# Flush Directory Service cache
|
||||
flush = "dscacheutil -flushcache && killall -HUP mDNSResponder";
|
||||
|
||||
# Recursively delete `.DS_Store` files
|
||||
cleanup = "find . -type f -name '*.DS_Store' -ls -delete";
|
||||
|
||||
# Clear the screen
|
||||
c = "clear";
|
||||
|
||||
# Empty the Trash on all mounted volumes and the main HDD
|
||||
# Also, clear Apple’s System Logs to improve shell startup speed
|
||||
emptytrash = "sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash; sudo rm -rfv /private/var/log/asl/*.asl";
|
||||
};
|
||||
initExtra = builtins.readFile ./zshrc.sh;
|
||||
plugins = [
|
||||
{
|
||||
name = "cht-completion";
|
||||
src = chtCompletionScript;
|
||||
}
|
||||
];
|
||||
antidote = {
|
||||
enable = true;
|
||||
plugins = [
|
||||
"ohmyzsh/ohmyzsh path:plugins/brew"
|
||||
"ohmyzsh/ohmyzsh path:plugins/bundler"
|
||||
"ohmyzsh/ohmyzsh path:plugins/colored-man-pages"
|
||||
"ohmyzsh/ohmyzsh path:plugins/colorize"
|
||||
"ohmyzsh/ohmyzsh path:plugins/dotenv"
|
||||
"ohmyzsh/ohmyzsh path:plugins/extract"
|
||||
"ohmyzsh/ohmyzsh path:plugins/fzf"
|
||||
"ohmyzsh/ohmyzsh path:plugins/gem"
|
||||
"ohmyzsh/ohmyzsh path:plugins/git"
|
||||
"ohmyzsh/ohmyzsh path:plugins/git-extras"
|
||||
"ohmyzsh/ohmyzsh path:plugins/gitignore"
|
||||
"ohmyzsh/ohmyzsh path:plugins/gulp"
|
||||
"ohmyzsh/ohmyzsh path:plugins/history-substring-search"
|
||||
"ohmyzsh/ohmyzsh path:plugins/jira"
|
||||
"ohmyzsh/ohmyzsh path:plugins/man"
|
||||
"ohmyzsh/ohmyzsh path:plugins/node"
|
||||
"ohmyzsh/ohmyzsh path:plugins/npm"
|
||||
"ohmyzsh/ohmyzsh path:plugins/pip"
|
||||
"ohmyzsh/ohmyzsh path:plugins/pyenv"
|
||||
"ohmyzsh/ohmyzsh path:plugins/python"
|
||||
"ohmyzsh/ohmyzsh path:plugins/rsync"
|
||||
"ohmyzsh/ohmyzsh path:plugins/ssh-agent"
|
||||
"ohmyzsh/ohmyzsh path:plugins/sudo"
|
||||
"ohmyzsh/ohmyzsh path:plugins/tmux"
|
||||
# "ohmyzsh/ohmyzsh path:plugins/tmux-cssh"
|
||||
"ohmyzsh/ohmyzsh path:plugins/tmuxinator"
|
||||
"ohmyzsh/ohmyzsh path:plugins/vagrant"
|
||||
"ohmyzsh/ohmyzsh path:plugins/virtualenv"
|
||||
"ohmyzsh/ohmyzsh path:plugins/yarn"
|
||||
"ohmyzsh/ohmyzsh path:plugins/z"
|
||||
"ohmyzsh/ohmyzsh path:plugins/zsh-interactive-cd"
|
||||
"zsh-users/zsh-autosuggestions"
|
||||
"zsh-users/zsh-syntax-highlighting"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
home.packages = [ chtCompletionScript ];
|
||||
|
||||
home.activation = {
|
||||
zlcompile = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||
$DRY_RUN_CMD ${pkgs.zsh}/bin/zsh -c "for f in $HOME/.zshrc $HOME/.zshenv; do zcompile -R -- \$f.zwc \$f; done"
|
||||
'';
|
||||
};
|
||||
}
|
||||
190
nix/home/zsh/zshrc.sh
Normal file
190
nix/home/zsh/zshrc.sh
Normal file
@@ -0,0 +1,190 @@
|
||||
CASE_SENSITIVE="true" # Case-sensitive completion
|
||||
DISABLE_AUTO_TITLE="true" # Disable auto-setting terminal title
|
||||
COMPLETION_WAITING_DOTS="true"
|
||||
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=7,bg=bold,underline"
|
||||
|
||||
# Bindkey
|
||||
bindkey -v
|
||||
bindkey -M viins '^r' fzf-history-widget # (r)everse history search
|
||||
bindkey -M viins '^f' fzf-file-widget # (f)ile / (t)
|
||||
bindkey -M viins '^z' fzf-cd-widget # (z) jump
|
||||
|
||||
# TMUX
|
||||
if [ -n "$TMUX" ]; then
|
||||
eval "$(tmux show-environment -s NVIM_LISTEN_ADDRESS 2>/dev/null)"
|
||||
else
|
||||
export NVIM_LISTEN_ADDRESS=/tmp/nvimsocket
|
||||
fi
|
||||
|
||||
# Set ZSH_CACHE_DIR and ensure it exists
|
||||
export ZSH_CACHE_DIR="$HOME/.cache/zsh"
|
||||
mkdir -p "$ZSH_CACHE_DIR/completions"
|
||||
|
||||
# Ensure gh completions are sourced if gh is installed
|
||||
if command -v gh &>/dev/null; then
|
||||
eval "$(gh completion -s zsh)"
|
||||
fi
|
||||
|
||||
# Atuin
|
||||
if command -v atuin &>/dev/null; then
|
||||
eval "$(atuin init zsh)"
|
||||
fi
|
||||
|
||||
# Search and preview GitHub pull requests
|
||||
function ghpr() {
|
||||
GH_FORCE_TTY=100% gh pr list | fzf --ansi --preview 'GH_FORCE_TTY=100% gh pr view {1}' --preview-window down --header-lines 3 | awk '{print $1}' | xargs gh pr checkout
|
||||
}
|
||||
|
||||
# Delete all node_modules folders in a folder and subfolders
|
||||
function deleteNodeModules() {
|
||||
find . -name "node_modules" -type d -exec rm -rf '{}' +
|
||||
}
|
||||
|
||||
function homebrewBackup() {
|
||||
cd ~/.dotfiles/
|
||||
brew bundle dump --describe -f
|
||||
}
|
||||
|
||||
function homebrewRestore() {
|
||||
brew bundle --file ~/.dotfiles/Brewfile
|
||||
}
|
||||
|
||||
# Server
|
||||
server() {
|
||||
browser-sync start --server --files "**"
|
||||
}
|
||||
|
||||
# Determine size of a file or total size of a directory
|
||||
fs() {
|
||||
if du -b /dev/null >/dev/null 2>&1; then
|
||||
local arg=-sbh
|
||||
else
|
||||
local arg=-sh
|
||||
fi
|
||||
if [[ -n "$@" ]]; then
|
||||
du $arg -- "$@"
|
||||
else
|
||||
du $arg .[^.]* *
|
||||
fi
|
||||
}
|
||||
|
||||
# Modified version where you can press
|
||||
# - CTRL-O to open with `open` command,
|
||||
# - CTRL-E or Enter key to open with the $EDITOR
|
||||
fo() {
|
||||
IFS=$'\n' out=("$(fzf-tmux --query="$1" --exit-0 --expect=ctrl-o,ctrl-e)")
|
||||
key=$(head -1 <<<"$out")
|
||||
file=$(head -2 <<<"$out" | tail -1)
|
||||
if [ -n "$file" ]; then
|
||||
[ "$key" = ctrl-o ] && open "$file" || ${EDITOR:-vim} "$file"
|
||||
fi
|
||||
}
|
||||
|
||||
# fcd - cd into directory
|
||||
fcd() {
|
||||
cd $(find * -type d | fzf --preview 'tree -C {} | head -50')
|
||||
}
|
||||
|
||||
# fhcd – Jump to home directory and search for directories
|
||||
fhcd() {
|
||||
cd $HOME
|
||||
cd $(find * -type d | fzf --preview 'tree -C {} | head -50')
|
||||
}
|
||||
|
||||
# fdr - cd to selected parent directory
|
||||
fdr() {
|
||||
local declare dirs=()
|
||||
get_parent_dirs() {
|
||||
if [[ -d "${1}" ]]; then dirs+=("$1"); else return; fi
|
||||
if [[ "${1}" == '/' ]]; then
|
||||
for _dir in "${dirs[@]}"; do echo $_dir; done
|
||||
else
|
||||
get_parent_dirs $(dirname "$1")
|
||||
fi
|
||||
}
|
||||
|
||||
local DIR=$(get_parent_dirs $(realpath "${1:-$(pwd)}") | fzf-tmux --tac)
|
||||
cd "$DIR"
|
||||
}
|
||||
|
||||
# Find in files with ripgrep and fzf and open on that line
|
||||
# -> Works together with Vim Plugin bogado/file-line
|
||||
frg() {
|
||||
file=$(rg . --line-number | fzf | cut -d: -f1 -f2)
|
||||
if [ "$file" != "" ]; then
|
||||
nvim $file
|
||||
fi
|
||||
}
|
||||
|
||||
# fkill - kill process
|
||||
fkill() {
|
||||
pid=$(ps -ef | sed 1d | fzf -m | awk '{print $2}')
|
||||
|
||||
if [ "x$pid" != "x" ]; then
|
||||
kill -${1:-9} $pid
|
||||
fi
|
||||
}
|
||||
|
||||
# fco - checkout git branch/tag
|
||||
fco() {
|
||||
local tags branches target
|
||||
tags=$(
|
||||
git tag | awk '{print "\x1b[31;1mtag\x1b[m\t" $1}'
|
||||
) || return
|
||||
branches=$(
|
||||
git branch --all | grep -v HEAD |
|
||||
sed "s/.* //" | sed "s#remotes/[^/]*/##" |
|
||||
sort -u | awk '{print "\x1b[34;1mbranch\x1b[m\t" $1}'
|
||||
) || return
|
||||
target=$(
|
||||
(
|
||||
echo "$tags"
|
||||
echo "$branches"
|
||||
) |
|
||||
fzf-tmux -- --no-hscroll --ansi +m -d "\t" -n 2
|
||||
) || return
|
||||
git checkout $(echo "$target" | awk '{print $2}')
|
||||
}
|
||||
|
||||
# fcoc - checkout git commit
|
||||
fcoc() {
|
||||
local commits commit
|
||||
commits=$(git log --pretty=oneline --abbrev-commit --reverse) &&
|
||||
commit=$(echo "$commits" | fzf --tac +s +m -e) &&
|
||||
git checkout $(echo "$commit" | sed "s/ .*//")
|
||||
}
|
||||
|
||||
# fshow - git commit browser
|
||||
fshow() {
|
||||
git log --graph --color=always \
|
||||
--format="%C(auto)%h%d %s %C(black)%C(bold)%cr" "$@" |
|
||||
fzf --ansi --no-sort --reverse --tiebreak=index --bind=ctrl-s:toggle-sort \
|
||||
--bind "ctrl-m:execute:
|
||||
(grep -o '[a-f0-9]\{7\}' | head -1 |
|
||||
xargs -I % sh -c 'git show --color=always % | less -R') << 'FZF-EOF'
|
||||
{}
|
||||
FZF-EOF"
|
||||
}
|
||||
|
||||
# Search z history with fzf
|
||||
fz() {
|
||||
[ $# -gt 0 ] && _z "$*" && return
|
||||
cd "$(_z -l 2>&1 | fzf --height 40% --nth 2.. --reverse --inline-info +s --tac --query "${*##-* }" | sed 's/^[0-9,.]* *//')"
|
||||
}
|
||||
|
||||
# Browse Brave history
|
||||
fbh() {
|
||||
local cols sep
|
||||
cols=$((COLUMNS / 3))
|
||||
sep='{{::}}'
|
||||
|
||||
# Copy History DB to circumvent the lock
|
||||
# See http://stackoverflow.com/questions/8936878 for the file path
|
||||
cp -f ~/Library/Application\ Support/BraveSoftware/Brave-Browser/Default/History /tmp/h
|
||||
|
||||
sqlite3 -separator $sep /tmp/h \
|
||||
"select substr(title, 1, $cols), url
|
||||
from urls order by last_visit_time desc" |
|
||||
awk -F $sep '{printf "%-'$cols's \x1b[36m%s\n", $1, $2}' |
|
||||
fzf --ansi --multi | sed 's#.*\(https*://\)#\1#' | xargs open
|
||||
}
|
||||
Reference in New Issue
Block a user