FISH: Configuration pour ce nouveau SHELL (en cours de test)

This commit is contained in:
Olivier DOSSMANN 2020-04-26 17:23:28 +02:00
parent ab2f042909
commit bd1041a3f6
12 changed files with 463 additions and 0 deletions

View File

@ -0,0 +1 @@
fisher complete

157
.config/fish/config.fish Normal file
View File

@ -0,0 +1,157 @@
#
# Variables d'environnement
#
set BROWSER chromium
set EDITOR nvim
#
# Aliases
#
# PERSO #
alias e 'nvim'
alias r 'nvim -R'
alias ls 'exa'
alias rgrep 'rg --no-ignore'
alias rero "ALIAS=rero /home/od/rero/logik/agnes"
alias dotfiles '/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
# GIT #
alias g 'git'
alias ga 'git add'
alias gaa 'git add --all'
alias gapa 'git add --patch'
alias gb 'git branch'
alias gba 'git branch -a'
#alias gbda 'git branch --no-color --merged | command grep -vE "^(\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d'
alias gbl 'git blame -b -w'
alias gbnm 'git branch --no-merged'
alias gbr 'git branch --remote'
alias gbs 'git bisect'
alias gbsb 'git bisect bad'
alias gbsg 'git bisect good'
alias gbsr 'git bisect reset'
alias gbss 'git bisect start'
alias gc 'git commit -v'
alias gc! 'git commit -v --amend'
alias gcn! 'git commit -v --no-edit --amend'
alias gca 'git commit -v -a'
alias gca! 'git commit -v -a --amend'
alias gcan! 'git commit -v -a --no-edit --amend'
alias gcans! 'git commit -v -a -s --no-edit --amend'
alias gcam 'git commit -a -m'
alias gcb 'git checkout -b'
alias gcf 'git config --list'
alias gcl 'git clone --recursive'
alias gclean 'git clean -fd'
alias gpf 'git push --force-with-lease'
alias gpf! 'git push --force'
alias gpristine 'git reset --hard & git clean -dfx'
alias gcm 'git checkout master'
alias gcmsg 'git commit -m'
alias gco 'git checkout'
alias gcount 'git shortlog -sn'
alias gcp 'git cherry-pick'
alias gcs 'git commit -S'
alias gd 'git diff'
alias gdca 'git diff --cached'
alias gdct 'git describe --tags `git rev-list --tags --max-count 1`'
alias gdt 'git diff-tree --no-commit-id --name-only -r'
alias gdw 'git diff --word-diff'
alias gf 'git fetch'
alias gfa 'git fetch --all --prune'
alias gfo 'git fetch origin'
alias gg 'git gui citool'
alias gga 'git gui citool --amend'
alias ggpull "git pull origin (git_branch_name)"
alias ggpush "git push origin (git_branch_name)"
alias ggsup 'git branch --set-upstream-to origin/(git_branch_name)'
alias ggpur 'ggu'
alias gignore 'git update-index --assume-unchanged'
alias gignored 'git ls-files -v | grep "^[[:lower:]]"'
alias git-svn-dcommit-push 'git svn dcommit & git push github master:svntrunk'
alias gk '\gitk --all --branches'
#alias gke '\gitk --all $(git log -g --pretty format:%h)'
alias gl 'git pull'
alias glg 'git log --stat'
alias glgp 'git log --stat -p'
alias glgg 'git log --graph'
alias glgga 'git log --graph --decorate --all'
alias glgm 'git log --graph --max-count 10'
alias glo 'git log --oneline --decorate'
alias glol "git log --graph --pretty format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
alias glola "git log --graph --pretty format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all"
alias glog 'git log --oneline --decorate --graph'
alias gloga 'git log --oneline --decorate --graph --all'
alias glp "_git_log_prettily"
alias gm 'git merge'
alias gmom 'git merge origin/master'
alias gmt 'git mergetool --no-prompt'
alias gmtvim 'git mergetool --no-prompt --tool vimdiff'
alias gmum 'git merge upstream/master'
alias gp 'git push'
alias gpd 'git push --dry-run'
alias gpoat 'git push origin --all & git push origin --tags'
alias gpu 'git push upstream'
alias gpv 'git push -v'
alias gr 'git remote'
alias gra 'git remote add'
alias grb 'git rebase'
alias grba 'git rebase --abort'
alias grbc 'git rebase --continue'
alias grbi 'git rebase -i'
alias grbm 'git rebase master'
alias grbs 'git rebase --skip'
alias grh 'git reset HEAD'
alias grhh 'git reset --hard'
alias grmv 'git remote rename'
alias grrm 'git remote remove'
alias grset 'git remote set-url'
#alias grt 'cd $(git rev-parse --show-toplevel || echo ".")'
alias gru 'git reset --'
alias grup 'git remote update'
alias grv 'git remote -v'
alias gsb 'git status -sb'
alias gsd 'git svn dcommit'
alias gsi 'git submodule init'
alias gsps 'git show --pretty short --show-signature'
alias gsr 'git svn rebase'
alias gss 'git status -s'
alias gst 'git status'
alias gsta 'git stash save'
alias gstaa 'git stash apply'
alias gstd 'git stash drop'
alias gstl 'git stash list'
alias gstp 'git stash pop'
alias gsts 'git stash show --text'
alias gsu 'git submodule update'
alias gsw 'git switch'
alias gswc 'git switch -c'
alias gts 'git tag -s'
alias gtv 'git tag | sort -V'
alias gunignore 'git update-index --no-assume-unchanged'
alias gunwip 'git log -n 1 | grep -q -c "\-\-wip\-\-" & git reset HEAD~1'
alias gup 'git pull --rebase'
alias gupv 'git pull --rebase -v'
alias glum 'git pull upstream master'
alias gwch 'git whatchanged -p --abbrev-commit --pretty medium'
#alias gwip 'git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit -m "--wip--"'

View File

@ -0,0 +1,32 @@
# This file contains fish universal variable definitions.
# VERSION: 3.0
SETUVAR __fish_initialized:3100
SETUVAR fish_color_autosuggestion:4c566a
SETUVAR fish_color_cancel:\x2dr
SETUVAR fish_color_command:81a1c1
SETUVAR fish_color_comment:434c5e
SETUVAR fish_color_cwd:green
SETUVAR fish_color_cwd_root:red
SETUVAR fish_color_end:88c0d0
SETUVAR fish_color_error:ebcb8b
SETUVAR fish_color_escape:00a6b2
SETUVAR fish_color_history_current:\x2d\x2dbold
SETUVAR fish_color_host:normal
SETUVAR fish_color_host_remote:yellow
SETUVAR fish_color_match:\x2d\x2dbackground\x3dbrblue
SETUVAR fish_color_normal:normal
SETUVAR fish_color_operator:00a6b2
SETUVAR fish_color_param:eceff4
SETUVAR fish_color_quote:a3be8c
SETUVAR fish_color_redirection:b48ead
SETUVAR fish_color_search_match:bryellow\x1e\x2d\x2dbackground\x3dbrblack
SETUVAR fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblack
SETUVAR fish_color_status:red
SETUVAR fish_color_user:brgreen
SETUVAR fish_color_valid_path:\x2d\x2dunderline
SETUVAR fish_greeting:Bienvenue\x20dans\x20fish\x2c\x20le\x20shell\x20amical\x20et\x20interactif\x0aType\x20\x60help\x60\x20for\x20instructions\x20on\x20how\x20to\x20use\x20fish
SETUVAR fish_key_bindings:fish_default_key_bindings
SETUVAR fish_pager_color_completion:normal
SETUVAR fish_pager_color_description:B3A06D\x1eyellow
SETUVAR fish_pager_color_prefix:white\x1e\x2d\x2dbold\x1e\x2d\x2dunderline
SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan

1
.config/fish/fishfile Normal file
View File

@ -0,0 +1 @@
edc/bass

View File

@ -0,0 +1,128 @@
"""
To be used with a companion fish function like this:
function refish
set -l _x (python /tmp/bass.py source ~/.nvm/nvim.sh ';' nvm use iojs); source $_x; and rm -f $_x
end
"""
from __future__ import print_function
import json
import os
import signal
import subprocess
import sys
import traceback
BASH = 'bash'
FISH_READONLY = [
'PWD', 'SHLVL', 'history', 'pipestatus', 'status', 'version',
'FISH_VERSION', 'fish_pid', 'hostname', '_', 'fish_private_mode'
]
IGNORED = [
'PS1', 'XPC_SERVICE_NAME'
]
def ignored(name):
if name == 'PWD': # this is read only, but has special handling
return False
# ignore other read only variables
if name in FISH_READONLY:
return True
if name in IGNORED or name.startswith("BASH_FUNC"):
return True
return False
def escape(string):
# use json.dumps to reliably escape quotes and backslashes
return json.dumps(string).replace(r'$', r'\$')
def comment(string):
return '\n'.join(['# ' + line for line in string.split('\n')])
def gen_script():
# Use the following instead of /usr/bin/env to read environment so we can
# deal with multi-line environment variables (and other odd cases).
env_reader = "%s -c 'import os,json; print(json.dumps({k:v for k,v in os.environ.items()}))'" % (sys.executable)
args = [BASH, '-c', env_reader]
output = subprocess.check_output(args, universal_newlines=True)
old_env = output.strip()
pipe_r, pipe_w = os.pipe()
if sys.version_info >= (3, 4):
os.set_inheritable(pipe_w, True)
command = 'eval $1 && ({}; alias) >&{}'.format(
env_reader,
pipe_w
)
args = [BASH, '-c', command, 'bass', ' '.join(sys.argv[1:])]
p = subprocess.Popen(args, universal_newlines=True, close_fds=False)
os.close(pipe_w)
with os.fdopen(pipe_r) as f:
new_env = f.readline()
alias = f.read()
if p.wait() != 0:
raise subprocess.CalledProcessError(
returncode=p.returncode,
cmd=' '.join(sys.argv[1:]),
output=new_env + alias
)
new_env = new_env.strip()
old_env = json.loads(old_env)
new_env = json.loads(new_env)
script_lines = []
for k, v in new_env.items():
if ignored(k):
continue
v1 = old_env.get(k)
if not v1:
script_lines.append(comment('adding %s=%s' % (k, v)))
elif v1 != v:
script_lines.append(comment('updating %s=%s -> %s' % (k, v1, v)))
# process special variables
if k == 'PWD':
script_lines.append('cd %s' % escape(v))
continue
else:
continue
if k == 'PATH':
value = ' '.join([escape(directory)
for directory in v.split(':')])
else:
value = escape(v)
script_lines.append('set -g -x %s %s' % (k, value))
for var in set(old_env.keys()) - set(new_env.keys()):
script_lines.append(comment('removing %s' % var))
script_lines.append('set -e %s' % var)
script = '\n'.join(script_lines)
return script + '\n' + alias
script_file = os.fdopen(3, 'w')
if not sys.argv[1:]:
print('__bass_usage', file=script_file, end='')
sys.exit(0)
try:
script = gen_script()
except subprocess.CalledProcessError as e:
sys.exit(e.returncode)
except Exception:
print('Bass internal error!', file=sys.stderr)
raise # traceback will output to stderr
except KeyboardInterrupt:
signal.signal(signal.SIGINT, signal.SIG_DFL)
os.kill(os.getpid(), signal.SIGINT)
else:
script_file.write(script)

View File

@ -0,0 +1,29 @@
function bass
set -l bash_args $argv
set -l bass_debug
if test "$bash_args[1]_" = '-d_'
set bass_debug true
set -e bash_args[1]
end
set -l script_file (mktemp)
if command -v python3 >/dev/null 2>&1
command python3 (dirname (status -f))/__bass.py $bash_args 3>$script_file
else
command python (dirname (status -f))/__bass.py $bash_args 3>$script_file
end
set -l bass_status $status
if test $bass_status -ne 0
return $bass_status
end
if test -n "$bass_debug"
cat $script_file
end
source $script_file
command rm $script_file
end
function __bass_usage
echo "Usage: bass [-d] <bash-command>"
end

View File

@ -0,0 +1,3 @@
function fish_git_prompt
echo -n -s " coucou"
end

View File

@ -0,0 +1,16 @@
function fish_prompt --description 'Write out the prompt'
set -l normal (set_color normal)
# TODO: Changer couleur du suffixe si erreur
# TODO: Changer couleur du suffixe si root?
set -l prefix
set -l suffix ''
# If we're running via SSH, change the host color.
set -l color_host $fish_color_host
if set -q SSH_TTY
set color_host $fish_color_host_remote
end
echo -n -s (set_color magenta) $suffix $normal " "
end

View File

@ -0,0 +1,55 @@
function fish_right_prompt -d "Écris le prompt de droite"
set -l last_pipestatus $pipestatus
set -l last_status $status
set -l normal (set_color normal)
# Couleur spéciale de l'hôte
set -l color_host $fish_color_host
# suivant l'hôte :
switch (prompt_hostname)
case baloo sam
set color_host ffd700
case lueur
set color_host e75b80
end
# Couleur du répertoire courant
set -l color_cwd $fish_color_cwd
# Affichage de root si nécessaire
set -l hostname_prefix ''
# SI ROOT: ajout de 'root@' en plus coloré
if contains -- $USER root toor
if set -q fish_color_cwd_root
set color_root $fish_color_cwd_root
end
set hostname_prefix 'root@'
end
# Branche distante (affichage seulement si différente de 'origin')
set -l upstream (git config --get branch.(git rev-parse --abbrev-ref @ 2>/dev/null).remote 2>/dev/null)
set -l remote_branch_prompt ''
if test -n "$upstream" && test "$upstream" != "origin"
set remote_branch_prompt "$upstream"
end
# Write pipestatus
set -l prompt_status (__fish_print_pipestatus " [" "]" "|" (set_color $fish_color_status) (set_color --bold $fish_color_status) $last_pipestatus) $normal ' '
# Configuration de Git
# afficher les couleurs
set -g __fish_git_prompt_showcolorhints true
# couleurs choisies
set -g __fish_git_prompt_color_branch brmagenta # couleurs des branches
set -g __fish_git_prompt_color_upstream green # couleur des différences de commit
set -g __fish_git_prompt_color_untrackedfiles red # couleur des changements détectés
# plus d'infos (staged, etc.)
set -g __fish_git_prompt_show_informative_status true
# couleur du nom du dépôt distant utilisé
set -l git_remote_name_color 5fafff
# Caractères utilisés pour l'affichage de git
set -g __fish_git_prompt_char_upstream_ahead '⇡'
set -g __fish_git_prompt_char_upstream_behind '⇣'
echo -n -s $prompt_status (set_color $color_cwd) (prompt_pwd) $normal (set_color $git_remote_name_color) $remote_branch_prompt $normal (fish_vcs_prompt) $normal ' ' (set_color $color_root) $hostname_prefix (set_color -o $color_host) (prompt_hostname) $normal
end

View File

@ -0,0 +1,9 @@
function nvm
# N'utilise pas nvm pour Baloo, Lueur, Sam et ODT
switch (prompt_hostname)
case baloo lueur sam odt
return
case '*'
bass source /usr/share/nvm/init-nvm.sh --no-use ';' nvm $argv
end
end

View File

@ -0,0 +1,24 @@
#!/usr/bin/fish
#
# ▄▄▌ ▐ ▄▌·▄▄▄▄
# ██· █▌▐███▪ ██
# ██▪▐█▐▐▌▐█· ▐█▌
# ▐█▌██▐█▌██. ██
# ▀▀▀▀ ▀▪▀▀▀▀▀•
#
# wrapper for: fish
#
# place in:
# ~/.config/fish/functions/wd.fish
#
# @github.com/mfaerevaag/wd-c
function wd -d 'warp directory'
if set output (_wd $argv)
cd $output
else
for line in $output
echo $line
end
end
end

8
.warprc Normal file
View File

@ -0,0 +1,8 @@
buf:/home/od/projets/buffet
ans:/home/od/projets/buffet
virtualenv:/home/od/.virtualenvs/rero-ils-MSozJQq0/lib/python3.6/site-packages
logik:/home/od/rero/logik
patchwork:/home/od/projets/patchwork
ui:/home/od/rero/ui
ils:/home/od/rero/ils
rero:/home/od/rero/ils