Commit 8944c817 authored by hadret's avatar hadret

feat: initial commit.

parents
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist
*~
vim/bundle
vim/view
vim/.vim/autoload
zsh/.antigen/
# dotfiles
dotfiles are now being handled by [GNU
Stow](https://www.gnu.org/software/stow/). Rolling them out for the first time
is as easy as going through the folder structure from the inside of the
dotfiles repo directory and running `stow smth`. For example:
```bash
cd ~/.dotfiles
stow fish
```
# colors for exa
set -x EXA_COLORS "uu=38;5;249:un=38;5;241:gu=38;5;245:gn=38;5;241:da=38;5;245:sn=38;5;7:sb=38;5;7:ur=38;5;3;1:uw=38;5;5;1:ux=38;5;1;1:ue=38;5;1;1:gr=38;5;249:gw=38;5;249:gx=38;5;249:tr=38;5;249:tw=38;5;249:tx=38;5;249:fi=38;5;248:di=38;5;253:ex=38;5;1:xa=38;5;12:*.png=38;5;4:*.jpg=38;5;4:*.gif=38;5;4"
# GPG setup
set -x GPG_TTY "(tty)"
set -x SSH_AUTH_SOCK "$HOME/.gnupg/S.gpg-agent.ssh"
gpgconf --launch gpg-agent
# setup locale
set -x LANG "en_US.UTF-8"
set -x LC_COLLATE "en_US.UTF-8"
set -x LC_CTYPE "en_US.UTF-8"
set -x LC_MESSAGES "en_US.UTF-8"
set -x LC_MONETARY "en_US.UTF-8"
set -x LC_NUMERIC "en_US.UTF-8"
set -x LC_TIME "en_US.UTF-8"
set -x LC_ALL "en_US.UTF-8"
# setup fzf
set -x FZF_DEFAULT_OPTS '--color=bg+:#635196,fg:#b4b4b9,pointer:#ffb07b,marker:#ff761a,prompt:#34bfa4,info:#ffd392'
set -x FZF_DEFAULT_COMMAND "fd -t f -E Library -E Pictures -E Music"
set -x FZF_CTRL_T_COMMAND "$FZF_DEFAULT_COMMAND"
set -x FZF_CTRL_T_OPTS "--ansi --preview '(highlight -O ansi -l {} || cat {}) 2> /dev/null | head -100' --height 50%"
set -x FZF_ALT_C_COMMAND "fd -t d -E Library"
set -x FZF_FIND_FILE_COMMAND "$FZF_DEFAULT_COMMAND"
set -x FZF_FIND_FILE_OPTS "$FZF_CTRL_T_OPTS"
set -x FZF_CD_COMMAND "$FZF_ALT_C_COMMAND"
set -x FZF_CD_WITH_HIDDEN_COMMAND "fd --hidden -t d -E Library -E .git"
# set -x FZF_ENABLE_OPEN_PREVIEW 1
# setup default EDITOR
set -x EDITOR vim
# setup asdf
source ~/.asdf/asdf.fish
# load iTerm2 integration scripts
# source ~/.iterm2_shell_integration.fish
# load virtualfish integration
# eval (python -m virtualfish auto_activation update_python)
set -g VIRTUALFISH_VERSION 1.0.6
set -g VIRTUALFISH_PYTHON_EXEC /Users/hadret/.asdf/installs/python/3.7.4/bin/python
source /Users/hadret/.asdf/installs/python/3.7.4/lib/python3.7/site-packages/virtualfish/virtual.fish
source /Users/hadret/.asdf/installs/python/3.7.4/lib/python3.7/site-packages/virtualfish/auto_activation.fish
source /Users/hadret/.asdf/installs/python/3.7.4/lib/python3.7/site-packages/virtualfish/update_python.fish
emit virtualfish_did_setup_plugins
jethrokuan/z
patrickf3139/Colored-Man-Pages
jethrokuan/fzf
evanlucas/fish-kubectl-completions
oh-my-fish/plugin-bang-bang
function buba --description 'brew cu -a'
brew cu -a
end
function bubaf --description 'brew cu -af'
brew cu -af
end
function bubu --description 'port bubu to fish'
brew update
brew outdated
brew upgrade
brew cleanup
end
function cask -d 'provide brew cask functionality'
brew cask $argv
end
function cat --description 'use bat instead'
bat $argv
end
function certcheck --description 'check SSL certificate for a website'
curl --insecure -v "$argv" ^&1 | awk 'BEGIN { cert=0 } /^\* SSL connection/ { cert=1 } /^\*/ { if (cert) print }';
end
function fbr -d "Fuzzy-find and checkout a branch"
set -l IFS ''
set -l branches (git branch --all | grep -v HEAD | sed "s/.* //" | sed "s#remotes/[^/]*/##" | sort -u | awk '{print "\x1b[32;1mbranch\x1b[m\t" $1}')
set -l target (echo $branches | fzf --no-hscroll --ansi +m -d "\t" -n 2)
git checkout (echo "$target" | awk '{print $2}')
end
function fco -d "Fuzzy-find and checkout git tag or branch."
set -l IFS ''
set -l tags (git tag | awk '{print "\x1b[36;1mtag\x1b[m\t" $1}')
set -l branches (git branch --all | grep -v HEAD | sed "s/.* //" | sed "s#remotes/[^/]*/##" | sort -u | awk '{print "\x1b[32;1mbranch\x1b[m\t" $1}')
if test -z $tags
set targets (echo $branches)
else
set targets (echo $branches; echo $tags)
end
set -l target (echo $targets | fzf --no-hscroll --ansi +m -d "\t" -n 2)
git checkout (echo "$target" | awk '{print $2}')
end
function fish_prompt
set -l exit_code $status
test $SSH_TTY
and printf (set_color brred)$USER(set_color brwhite)'@'(set_color bryellow)(prompt_hostname)' '
test "$USER" = 'root'
and echo (set_color brred)"#"
# Main
if test $exit_code -ne 0
echo -n (set_color brcyan)(prompt_pwd) (set_color brred)'❯'(set_color brred)'❯'(set_color brred)'❯ '
else
echo -n (set_color brcyan)(prompt_pwd) (set_color brred)'❯'(set_color bryellow)'❯'(set_color brgreen)'❯ '
end
end
function fish_right_prompt -d "Write out the right prompt"
set_color normal
set -g __fish_git_prompt_showdirtystate 1
set -g __fish_git_prompt_showcolorhints
set -g __fish_git_prompt_showstashstate 1
set -g __fish_git_prompt_showuntrackedfiles 1
set -g __fish_git_prompt_showupstream informative
set -g __fish_git_prompt_color_branch brgreen
set -g __fish_git_prompt_color_dirtystate brmagenta
set -g __fish_git_prompt_color_stagedstate bryellow
set -g __fish_git_prompt_color_invalidstate brred
set -g __fish_git_prompt_color_untrackedfiles brcyan
set -g __fish_git_prompt_color_prefix brblack
set -g __fish_git_prompt_color_suffix brblack
if set -q VIRTUAL_ENV
echo -n -s (set_color brblack) "(" (set_color magenta) (basename "$VIRTUAL_ENV") (set_color brblack) ")"
end
printf '%s ' (__fish_git_prompt)
set_color normal
end
function fishrc --description 'edit config.fish file'
vim ~/.config/fish/config.fish
end
function fs --description 'Switch tmux session'
if test $TMUX
tmux list-sessions -F "#{session_name}" | fzf | read -l result; and tmux switch-client -t "$result"
else
tmux attach-session -t "local"
end
end
function fshow -d "fzf-based git commit preview."
# if no arguments passed, use current branch
if not count $argv > /dev/null
set argv (git branch | grep "^\*" | string trim -c "\* ")
end
git log --graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr" "$argv" | 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"
end
function ft --description 'start default tmux session'
mux start local
end
function gcomp --description 'Chose GCloud compute instance to work with'
set gcompcache ~/.config/gcloud/gcomp-(gproj current | awk '{ print $1}').cache
if not test -s $gcompcache
gcloud compute instances list > $gcompcache
end
# if no arguments passed, print current project
if not count $argv > /dev/null
set argv list
end
# print & switch all the things!
switch $argv
case cc clear-cache
rm $gcompcache
echo "Cache cleared!"
case uc update-cache
gcloud compute instances list > $gcompcache
echo "Cache updated!"
case l ls list
cat -p $gcompcache
case d describe
gcloud compute instances describe (cat -p $gcompcache | awk 'NR>1 { print $1}' | fzf) | less
case s ssh
gcloud compute ssh (cat -p $gcompcache | awk 'NR>1 { print $1}' | fzf)
case f firewall
gcloud compute firewall-rules list
case '*'
echo Wrong usage you bastardo\!
end
end
function gen_ssh --description 'concat config files for ssh'
cat ~/.ssh/config.d/*.conf > ~/.ssh/config
end
set -x GPG_TTY "(tty)"
set -x SSH_AUTH_SOCK "$HOME/.gnupg/S.gpg-agent.ssh"
gpgconf --launch gpg-agent
function gproj --description 'Chose GCloud project to work with'
set gprojcache ~/.config/gcloud/gproj.cache
if not test -s $gprojcache
gcloud projects list > $gprojcache
end
# if no arguments passed, print current project
if not count $argv > /dev/null
set argv current
end
# print & switch all the things!
switch $argv
case cc clear-cache
rm $gprojcache
echo "Cache cleared!"
case uc update-cache
gcloud projects list > $gprojcache
echo "Cache updated!"
case l ls list
cat -p $gprojcache
case s set
cat -p $gprojcache | sed 1d | fzf | awk '{print $1}' | xargs gcloud config set project
case c current
grep (awk -F'= ' '/project/ { print $2}' ~/.config/gcloud/configurations/config_default) $gprojcache
case '*'
echo Wrong usage you bastardo\!
end
end
function l --description 'ls -l'
exa -l --group-directories-first --git --header $argv
end
alias ll l
function l1 --description 'list in single column'
exa -1 --group-directories-first --git $argv
end
function l1a --description 'list in single column including hidden'
exa -Fa1 --group-directories-first --git $argv
end
function la --description 'list with hidden stuff'
exa -Fa --group-directories-first --git --header $argv
end
function lla --description 'long list with hidden'
exa -la --group-directories-first --git --header $argv
end
function lle
exa -lbBghHimS --group-directories-first --git --header $argv
end
function ls --description 'list'
exa --group-directories-first --git --header $argv
end
function ltree
exa -hTl $argv
end
function mkcd --description 'create folder and cd to it'
set -l folder $argv
mkdir -p $folder
cd $folder
end
function mutt --description 'neomutt'
neomutt $argv
end
function mux --description 'be shorted when using tmuxinator'
tmuxinator $argv
end
function myip --description 'show my IP address'
curl -s https://api.ipify.org
end
function ncdu --description 'ncdu with colors etc.'
command ncdu --color dark -rr -x --exclude .git --exclude node_modules $argv
end
function path --description 'show currect PATH'
echo $PATH | xargs -n1
end
function ping --description 'prettyping'
prettyping $argv
end
function rangerc --description 'edit ranger config file'
vim ~/.dotfiles/ranger/.config/ranger/rc.conf
end
function rr
set -x tempfile (mktemp -t tmp.XXXXXX)
ranger --choosedir="$tempfile" $argv
if test -f $tempfile
cd (cat $tempfile)
end
set -e tempfile
rm -f -- $tempfile
end
alias rcd rr
function ssh --description 'generate ssh config file, export TERM, connect'
env TERM=xterm-256color ssh $argv
end
function vimrc --description 'edit vim config files'
vim ~/.dotfiles/vim/.vimrc ~/.dotfiles/vim/.vimrc.plug
end
function yoink
open -a Yoink $argv
end
[alias]
# View abbreviated SHA, description, and history graph of the latest 20
l = log --pretty=oneline -n 20 --graph --abbrev-commit
# View even nicer log
ll = log --oneline --decorate --color --graph
# View the current working tree status using the short format
s = status -s
# View the current working tree status
st = status
# Sign the commit with your GPG key:
sign = !"git commit -S -m"
# Show the diff between the latest commit and the current state
d = !"git diff-index --quiet HEAD -- || clear; git --no-pager diff --patch-with- stat"
# `git di $number` shows the diff between the state `$number` revisions ago
# and the current state
di = !"d() { git diff --patch-with-stat HEAD~$1; }; git diff-index --quiet HEAD -- || clear; d"
# Make use of gdsf if available:
dsf = "!f() { [ -z \"$GIT_PREFIX\" ] || cd \"$GIT_PREFIX\" && git diff --color \"$@\" | diff-so-fancy | less --tabs=4 -RFX; }; f"
# Pull in remote changes for the current repository and all its submodules
p = !"git pull; git submodule foreach git pull origin master"
# Clone a repository including all submodules
c = clone --recursive
# Commit all changes
ca = !git add -A && git commit -av
# Commit all changes and write commit message
cam = !git commit -a -m
# Switch to a branch, creating it if necessary
go = "!f() { git checkout -b \"$1\" 2> /dev/null || git checkout \"$1\"; }; f"
# Show verbose output about tags, branches or remotes
tags = tag -l
branches = branch -a
remotes = remote -v
# Amend the currently staged files to the latest commit
amend = commit --amend --reuse-message=HEAD
# Credit an author on the latest commit
credit = "!f() { git commit --amend --author \"$1 <$2>\" -C HEAD; }; f"
# Interactive rebase with the given number of latest commits
reb = "!r() { git rebase -i HEAD~$1; }; r"
# Remove the old tag with this name and tag the latest commit with it
retag = "!r() { git tag -d $1 && git push origin :refs/tags/$1 && git tag $1;}; r"
# Find branches containing commit
fb = "!f() { git branch -a --contains $1; }; f"
# Find tags containing commit
ft = "!f() { git describe --always --contains $1; }; f"
# Find commits by source code
fc = "!f() { git log --pretty=format:'%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d' --decorate --date=short -S$1; }; f"
# Find commits by commit message
fm = "!f() { git log --pretty=format:'%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d' --decorate --date=short --grep=$1; }; f"
# Remove branches that have already been merged with master
# a.k.a. ‘delete merged’
dm = "!git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d"
# List contributors with number of commits
contributors = shortlog --summary --numbered
[apply]
whitespace = fix
[color]
ui = true
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold # line info
old = red # deletions
new = green # additions
[color "status"]
added = yellow
changed = green
untracked = cyan
[core]
# Treat spaces before tabs and all kinds of trailing whitespace as an error
# [default] trailing-space: looks for spaces at the end of a line
# [default] space-before-tab: looks for spaces before tabs at the beginning
# of a line
whitespace = space-before-tab,-indent-with-non-tab,trailing-space
# Make `git rebase` safer on macOS
# More info: http://www.git-tower.com/blog/make-git-rebase-safe-on-osx
trustctime = false
# Prevent showing files whose names contain non-ASCII symbols as unversioned.
# http://michael-kuehnel.de/git/2014/11/21/git-mac-osx-and-german-umlaute.html
precomposeunicode = false
# Exclude files for every single git repo from one global file
excludesfile = ~/.global_ignore
[diff]
# Detect copies as well as renames
renames = copies
# Enable an experimental heuristic that shifts the hunk boundary in an
# attempt to make the resulting patch easier to read
indentHeuristic = true
[diff "bin"]
# Use `hexdump` to diff binary files
textconv = hexdump -v -C
[merge]
# Include summaries of merged commits in newly created merge commit messages
log = true
[push]
default = simple
[credential]
helper = cache --timeout 3600
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[user]
# Set in ~/.gitconfig_local
[gpg]
# Set in ~/.gitconfig_local
[commit]
# Set in ~/.gitconfig_local
[include]
path = ~/.gitconfig_local
tags
site.retry
.vault
roles/external/*
*
!gpg.conf
!gpg-agent.conf
!.gitignore
enable-ssh-support
pinentry-program /usr/local/bin/pinentry-mac
default-cache-ttl 60480000
max-cache-ttl 60480000
write-env-file
use-standard-socket
use-agent
personal-cipher-preferences AES256 AES192 AES CAST5
personal-digest-preferences SHA512 SHA384 SHA256 SHA224
default-preference-list SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed
cert-digest-algo SHA512
s2k-digest-algo SHA512
s2k-cipher-algo AES256
charset utf-8
fixed-list-mode
no-comments
no-emit-version
keyid-format 0xlong
list-options show-uid-validity
verify-options show-uid-validity
with-fingerprint
*
!*/
!commands.py
!rc.conf
!.gitignore
!devicons.py
# This is a sample commands.py. You can add your own commands here.
#
# Please refer to commands_full.py for all the default commands and a complete
# documentation. Do NOT add them all here, or you may end up with defunct
# commands when upgrading ranger.
# You always need to import ranger.api.commands here to get the Command class:
from ranger.api.commands import *
# A simple command for demonstration purposes follows.
# -----------------------------------------------------------------------------
# You can import any python module as needed.
import os
# Any class that is a subclass of "Command" will be integrated into ranger as a
# command. Try typing ":my_edit<ENTER>" in ranger!
class my_edit(Command):
# The so-called doc-string of the class will be visible in the built-in
# help that is accessible by typing "?c" inside ranger.
""":my_edit <filename>
A sample command for demonstration purposes that opens a file in an editor.
"""
# The execute method is called when you run this command in ranger.
def execute(self):
# self.arg(1) is the first (space-separated) argument to the function.
# This way you can write ":my_edit somefilename<ENTER>".
if self.arg(1):
# self.rest(1) contains self.arg(1) and everything that follows
target_filename = self.rest(1)
else:
# self.fm is a ranger.core.filemanager.FileManager object and gives
# you access to internals of ranger.
# self.fm.thisfile is a ranger.container.file.File object and is a
# reference to the currently selected file.
target_filename = self.fm.thisfile.path
# This is a generic function to print text in ranger.
self.fm.notify("Let's edit the file " + target_filename + "!")
# Using bad=True in fm.notify allows you to print error messages:
if not os.path.exists(target_filename):
self.fm.notify("The given file does not exist!", bad=True)
return
# This executes a function from ranger.core.acitons, a module with a
# variety of subroutines that can help you construct commands.
# Check out the source, or run "pydoc ranger.core.actions" for a list.
self.fm.edit_file(target_filename)
# The tab method is called when you press tab, and should return a list of
# suggestions that the user will tab through.
# tabnum is 1 for <TAB> and -1 for <S-TAB> by default
def tab(self, tabnum):
# This is a generic tab-completion function that iterates through the
# content of the current directory.
return self._tab_directory_content()
class fzf_select(Command):
"""
:fzf_select
Find a file using fzf.
With a prefix argument select only directories.
See: https://github.com/junegunn/fzf
"""
def execute(self):
import subprocess
import os.path
if self.quantifier:
# match only directories
command="fd . ~ -t d --hidden -E '.rbenv' -E '.git' -E Library -E Pictures -E Music | fzf +m"
else:
# match files and directories
command="fd . ~ --hidden -E '.rbenv' -E '.git' -E Library -E Pictures -E Music | fzf +m"
fzf = self.fm.execute_command(command, stdout=subprocess.PIPE)
stdout, stderr = fzf.communicate()
if fzf.returncode == 0:
fzf_file = os.path.abspath(stdout.decode('utf-8').rstrip('\n'))
if os.path.isdir(fzf_file):
self.fm.cd(fzf_file)
else:
self.fm.select_file(fzf_file)
#!/usr/bin/python
# coding=UTF-8
# These glyphs, and the mapping of file extensions to glyphs
# has been copied from the vimscript code that is present in
# https://github.com/ryanoasis/vim-devicons
import re;
import os;
# all those glyphs will show as weird squares if you don't have the correct patched font
# My advice is to use NerdFonts which can be found here:
# https://github.com/ryanoasis/nerd-fonts
file_node_extensions = {
'7z' : '',
'ai' : '',
'apk' : '',
'avi' : '',
'bat' : '',
'bmp' : '',
'bz2' : '',
'c' : '',
'c++' : '',
'cab' : '',
'cc' : '',
'clj' : '',
'cljc' : '',
'cljs' : '',
'coffee' : '',
'conf' : '',
'cp' : '',
'cpio' : '',
'cpp' : '',
'css' : '',
'cxx' : '',
'd' : '',
'dart' : '',
'db' : '',
'deb' : '',
'diff' : '',
'dump' : '',
'edn' : '',
'ejs' : '',
'epub' : '',
'erl' : '',
'f#' : '',
'fish' : '',
'flac' : '',
'flv' : '',
'fs' : '',
'fsi' : '',
'fsscript' : '',
'fsx' : '',
'gem' : '',
'gif' : '',
'go' : '',
'gz' : '',
'gzip' : '',
'hbs' : '',
'hrl' : '',
'hs' : '',
'htm' : '',
'html' : '',
'ico' : '',
'ini' : '',
'java' : '',
'jl' : '',
'jpeg' : '',
'jpg' : '',
'js' : '',
'json' : '',
'jsx' : '',
'less' : '',