Add fish, scripts and git
This commit is contained in:
parent
d0ad79e63b
commit
7d2921b09e
80
bin/columnize
Executable file
80
bin/columnize
Executable file
@ -0,0 +1,80 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# The MIT License (MIT)
|
||||||
|
|
||||||
|
# Copyright (c) 2015 Thomas Lovén
|
||||||
|
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
|
# copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
# SOFTWARE.
|
||||||
|
|
||||||
|
'Columnize text with ANSI escape codes'
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
import getopt
|
||||||
|
from os import path
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Python 3
|
||||||
|
from itertools import zip_longest
|
||||||
|
except ImportError:
|
||||||
|
# Python 2
|
||||||
|
from itertools import izip_longest as zip_longest
|
||||||
|
|
||||||
|
progname = path.basename(sys.argv[0])
|
||||||
|
|
||||||
|
def getlength(s):
|
||||||
|
'Find length of a string, ignoring escape sequences'
|
||||||
|
s = re.sub('\x1b\[[0-9;]*m', '', s)
|
||||||
|
return len(s)
|
||||||
|
|
||||||
|
def usage():
|
||||||
|
print('Columnize text with ANSI escape codes')
|
||||||
|
print('usage:', progname, '[-s sep]')
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
opts,args = getopt.getopt(sys.argv[1:], 'ts:')
|
||||||
|
opts = dict(opts)
|
||||||
|
except getopt.GetoptError as err:
|
||||||
|
print(progname, ':', str(err))
|
||||||
|
usage()
|
||||||
|
sys.exit(2)
|
||||||
|
|
||||||
|
splitchar = opts.get('-s', '\t')
|
||||||
|
|
||||||
|
lines = []
|
||||||
|
lengths = []
|
||||||
|
# Read each line from stdin
|
||||||
|
for line in sys.stdin:
|
||||||
|
cols = line.strip().split(splitchar)
|
||||||
|
lines.append(cols)
|
||||||
|
# Calculate the widths of each column
|
||||||
|
width = [getlength(col) for col in cols]
|
||||||
|
# Save the longest columns' lengths
|
||||||
|
lengths = map(max, zip_longest(lengths, width, fillvalue=0))
|
||||||
|
|
||||||
|
lengths = list(lengths)
|
||||||
|
for line in lines:
|
||||||
|
thisline = ''
|
||||||
|
for i,col in enumerate(line):
|
||||||
|
spaces = ' '*(lengths[i]-getlength(col)+1)
|
||||||
|
thisline += col + spaces
|
||||||
|
print(thisline.rstrip())
|
19
bin/prettygit
Executable file
19
bin/prettygit
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
HASH="%C(yellow)%h%C(reset)"
|
||||||
|
RELATIVE_TIME="%C(green)%ar%C(reset)"
|
||||||
|
AUTHOR="%C(blue)<%an>%C(reset)"
|
||||||
|
REFS="%C(red)%d%C(reset)"
|
||||||
|
SUBJECT="%C(reset)%s%C(reset)"
|
||||||
|
|
||||||
|
FORMAT="}$HASH}$RELATIVE_TIME}$AUTHOR}$REFS $SUBJECT"
|
||||||
|
|
||||||
|
function pretty_git_log() {
|
||||||
|
git log --graph --all --color=always --pretty="tformat:$FORMAT" $* |
|
||||||
|
sed -Ee 's/(^[^<]*) ago}/\1}/' |
|
||||||
|
columnize -t -s '}' |
|
||||||
|
less -FXR
|
||||||
|
}
|
||||||
|
|
||||||
|
# grep -v Merge |
|
||||||
|
pretty_git_log $@
|
11
fish/config.fish
Normal file
11
fish/config.fish
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
set -x DOTFILES $HOME/DOTFILES
|
||||||
|
|
||||||
|
if test -z "$FISH_SETUP_PATH"
|
||||||
|
set -x PATH $HOME/dotfiles/bin $PATH
|
||||||
|
set -x PATH . $PATH
|
||||||
|
|
||||||
|
set -x FISH_SETUP_PATH
|
||||||
|
end
|
||||||
|
|
||||||
|
set -x LANG sv_SE.UTF-8
|
||||||
|
set -x LC_ALL sv_SE.UTF-8
|
3
fish/functions/fish_greeting.fish
Normal file
3
fish/functions/fish_greeting.fish
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
function fish_greeting
|
||||||
|
|
||||||
|
end
|
23
fish/functions/fish_prompt.fish
Normal file
23
fish/functions/fish_prompt.fish
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
function fish_prompt
|
||||||
|
set -l status_copy $status
|
||||||
|
|
||||||
|
set -l host (hostname -s)
|
||||||
|
if set -q DEVCONTAINER
|
||||||
|
set host DEV
|
||||||
|
end
|
||||||
|
set_color (echo "$host" | md5sum | cut -c-6)
|
||||||
|
echo -sn $host
|
||||||
|
|
||||||
|
set_color yellow
|
||||||
|
echo -sn ':'
|
||||||
|
|
||||||
|
set_color normal
|
||||||
|
echo -sn (prompt_pwd)
|
||||||
|
|
||||||
|
if test "$status_copy" -ne 0
|
||||||
|
set_color red
|
||||||
|
else
|
||||||
|
set_color green
|
||||||
|
end
|
||||||
|
echo -sn ' > '
|
||||||
|
end
|
27
fish/functions/fish_right_prompt.fish
Normal file
27
fish/functions/fish_right_prompt.fish
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
function fish_right_prompt
|
||||||
|
set -l ref (git symbolic-ref HEAD ^/dev/null)
|
||||||
|
if test -z $ref
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
git diff --no-ext-diff --quiet --exit-code ^/dev/null
|
||||||
|
or set -l dirty 'yes'
|
||||||
|
|
||||||
|
git diff-index --cached --quiet HEAD -- ^/dev/null
|
||||||
|
or set -l staged 'yes'
|
||||||
|
|
||||||
|
set_color normal
|
||||||
|
echo -sn '['
|
||||||
|
|
||||||
|
if set -q staged
|
||||||
|
set_color yellow
|
||||||
|
else if set -q dirty
|
||||||
|
set_color red
|
||||||
|
else
|
||||||
|
set_color green
|
||||||
|
end
|
||||||
|
echo -sn (string replace refs/heads/ '' -- $ref)
|
||||||
|
|
||||||
|
set_color normal
|
||||||
|
echo -sn ']'
|
||||||
|
end
|
8
fish/functions/g.fish
Normal file
8
fish/functions/g.fish
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
function g --wraps git
|
||||||
|
if count $argv >/dev/null
|
||||||
|
git $argv
|
||||||
|
else
|
||||||
|
git status
|
||||||
|
git l -5
|
||||||
|
end
|
||||||
|
end
|
47
git/gitconfig
Normal file
47
git/gitconfig
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
[user]
|
||||||
|
name = Thomas Lovén
|
||||||
|
email = thomasloven@gmail.com
|
||||||
|
[credential]
|
||||||
|
helper = cache
|
||||||
|
[color]
|
||||||
|
ui = auto
|
||||||
|
branch = auto
|
||||||
|
diff = auto
|
||||||
|
status = auto
|
||||||
|
[color "branch"]
|
||||||
|
current = yellow reverse
|
||||||
|
local = yellow
|
||||||
|
remote = green
|
||||||
|
[color "diff"]
|
||||||
|
meta = yellow
|
||||||
|
frag = magenta
|
||||||
|
old = red
|
||||||
|
new = green
|
||||||
|
[color "status"]
|
||||||
|
added = yellow
|
||||||
|
changed = green
|
||||||
|
untracked = cyan
|
||||||
|
|
||||||
|
[push]
|
||||||
|
default = current
|
||||||
|
[core]
|
||||||
|
pager = less -F -X
|
||||||
|
|
||||||
|
[alias]
|
||||||
|
st = status
|
||||||
|
ci = commit
|
||||||
|
co = checkout
|
||||||
|
di = diff
|
||||||
|
dc = diff --cached
|
||||||
|
wd = diff --word-diff=color
|
||||||
|
amend = commit --amend
|
||||||
|
aa = add --all
|
||||||
|
b = branch
|
||||||
|
updateall = submodule foreach 'git pull'
|
||||||
|
l = !prettygit
|
||||||
|
p = "!echo $PATH"
|
||||||
|
la = !git l --all
|
||||||
|
r = !git l -30
|
||||||
|
ra = !git r --all
|
||||||
|
[merge]
|
||||||
|
tool = vimdiff
|
38
git/gitignore_global
Normal file
38
git/gitignore_global
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
*.com
|
||||||
|
*.class
|
||||||
|
*.dll
|
||||||
|
*.exe
|
||||||
|
*.o
|
||||||
|
*.so
|
||||||
|
|
||||||
|
*.7z
|
||||||
|
*.dmg
|
||||||
|
*.gz
|
||||||
|
*.iso
|
||||||
|
*.jar
|
||||||
|
*.rar
|
||||||
|
*.tar
|
||||||
|
*.zip
|
||||||
|
|
||||||
|
*.log
|
||||||
|
*.sql
|
||||||
|
*.sqlite
|
||||||
|
|
||||||
|
.DS_Store
|
||||||
|
.DS_Store?
|
||||||
|
._*
|
||||||
|
.Spotlight-V100
|
||||||
|
.Trashes
|
||||||
|
Icon?
|
||||||
|
ehthumbs.db
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
#Latex files
|
||||||
|
*.aux
|
||||||
|
*.bcf
|
||||||
|
*.blg
|
||||||
|
*.fdb_latexmk
|
||||||
|
*.fls
|
||||||
|
*.out
|
||||||
|
|
||||||
|
tags
|
20
install.sh
Executable file
20
install.sh
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
sudo -n apt-get update
|
||||||
|
sudo -n DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends fish vim
|
||||||
|
|
||||||
|
USER=`whoami`
|
||||||
|
sudo -n chsh $USER -s $(which fish)
|
||||||
|
|
||||||
|
echo "sv_SE.UTF-8 UTF-8" | sudo tee -a /etc/locale.gen
|
||||||
|
locale-gen
|
||||||
|
|
||||||
|
cat << EOF > ~/.gitconfig
|
||||||
|
[include]
|
||||||
|
path = ${HOME}/dotfiles/git/gitconfig
|
||||||
|
[core]
|
||||||
|
excludesfile = ${HOME}/dotfiles/git/gitignore_global
|
||||||
|
EOF
|
||||||
|
|
||||||
|
mkdir -p ~/.config/
|
||||||
|
ln -s ~/dotfiles/fish ~/.config/fish
|
10
test/Dockerfile
Normal file
10
test/Dockerfile
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
FROM mcr.microsoft.com/vscode/devcontainers/python:0-3.8
|
||||||
|
|
||||||
|
ENV DEVCONTAINER=1
|
||||||
|
|
||||||
|
WORKDIR /workspaces
|
||||||
|
|
||||||
|
COPY . /root/dotfiles
|
||||||
|
RUN /root/dotfiles/install.sh
|
||||||
|
|
||||||
|
CMD fish
|
9
test/run_test
Executable file
9
test/run_test
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
cd "$(dirname "$0")/.."
|
||||||
|
|
||||||
|
docker build . -t dotfiles -f test/Dockerfile --force-rm
|
||||||
|
|
||||||
|
docker run --rm -it dotfiles
|
||||||
|
|
||||||
|
docker rmi dotfiles
|
Loading…
x
Reference in New Issue
Block a user