Initial commit with fish, i3, nvim and polybar configuration

This commit is contained in:
Marc Sastre Rienitz
2020-05-17 20:00:08 +02:00
commit e15ad6aa30
30 changed files with 4032 additions and 0 deletions

38
.config/fish/aliases.fish Normal file
View File

@@ -0,0 +1,38 @@
# vim
alias vim="nvim"
alias vi="nvim"
# dotfiles
alias dotfiles='git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
# git aliases
alias gs='git status'
alias gd='git diff'
alias gdom='git diff origin/master'
alias gdomns='git diff origin/master --name-status'
alias ga='git add'
alias gall='git add --all'
alias gc='git commit'
alias gcm='git commit -m'
alias gcam='git commit -am'
alias gco='git checkout'
alias gcob='git checkout -b'
alias gm='git merge'
alias gmom='git merge origin/master'
alias gstash='git stash'
alias gsl='git stash list'
alias gsp='git stash pop'
alias gg='git lgb'
alias gpull='git pull'
alias gpush='git push'
# Postgres connections
alias local_psql='psql -d vilynx-db -U vilynx-web'
alias test_psql='psql -h postgres2.test.east.vilynx.com -d vilynx-db -U vilynx-web -p 5432'
alias prod_psql='ssh -f vilynxro@apache71.prod.east.vilynx.com -L 5440:localhost:5433 sleep 600; psql -h localhost -p 5440 -d vilynx-db -U vilynx-web'
# Redshift connection
alias test_redshift='psql -h redshift.test.east.vilynx.com -d dagda_insights -p 5439 -U dagda_user'
alias prod_redshift='psql -h redshift.east.vilynx.com -d dagda_insights -p 5439 -U dagda_user'
alias kraken_psql='psql -h kraken.vpn.vilynx.com -d vilynx-db -U vilynx-web -p 5432'

View File

@@ -0,0 +1 @@
fisher complete

View File

@@ -0,0 +1 @@
# fisher copy-user-key-bindings

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

@@ -0,0 +1,64 @@
set fish_greeting ""
#########################
# ALIASES #
#########################
alias ll='ls -alhF'
alias la='ls -A'
alias l='ls -CF'
. ~/.config/fish/aliases.fish
#########################
# FUNCTIONS #
#########################
# Manage AWS credentials
function aws-credentials
if test -d ~/.aws
rm ~/.aws;
end
ln -s .aws.$argv .aws
end
# Activate venv
function venv
if type -q deactivate
deactivate;
end
. ~/venv/$argv/bin/activate.fish
end
# Go to vilynx repo folder and activate venv
function repo
if test -d ~/vilynx/repos/$argv
cd ~/vilynx/repos/$argv;
venv $argv
else
echo "Could'nt find repo $argv"
end
end
# Clear postgresql cache
function clear_psql_cache
sudo service postgresql stop
echo 3 | sudo tee /proc/sys/vm/drop_caches
sudo service postgresql start
end
# Install "minimal" python packages
function setup-python
pip install autopep8 flake8 isort ipython pdbpp pip-tools pynvim
end
#########################
# THEME #
#########################
set -g theme_color_scheme zenburn
#########################
# MISC #
#########################
set -x VIRTUAL_ENV_DISABLE_PROMPT 1
set -x PGHOST localhost
set -x PYENV_ROOT "$HOME/.pyenv"
set -x PATH "$PYENV_ROOT/bin" $PATH

View File

@@ -0,0 +1,39 @@
# This file is automatically generated by the fish.
# Do NOT edit it directly, your changes will be overwritten.
SET FZF_DEFAULT_OPTS:\x2d\x2dheight\x2040\x25
SET FZF_LEGACY_KEYBINDINGS:1
SET FZF_PREVIEW_DIR_CMD:ls
SET FZF_PREVIEW_FILE_CMD:head\x20\x2dn\x2010
SET FZF_TMUX_HEIGHT:40\x25
SET __fish_classic_git_prompt_initialized:\x1d
SET __fish_init_2_39_8:\x1d
SET __fish_init_2_3_0:\x1d
SET fish_color_autosuggestion:555\x1ebrblack
SET fish_color_cancel:\x2dr
SET fish_color_command:\x2d\x2dbold
SET fish_color_comment:red
SET fish_color_cwd:green
SET fish_color_cwd_root:red
SET fish_color_end:brmagenta
SET fish_color_error:brred
SET fish_color_escape:bryellow\x1e\x2d\x2dbold
SET fish_color_history_current:\x2d\x2dbold
SET fish_color_host:normal
SET fish_color_match:\x2d\x2dbackground\x3dbrblue
SET fish_color_normal:normal
SET fish_color_operator:bryellow
SET fish_color_param:cyan
SET fish_color_quote:yellow
SET fish_color_redirection:brblue
SET fish_color_search_match:bryellow\x1e\x2d\x2dbackground\x3dbrblack
SET fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblack
SET fish_color_status:red
SET fish_color_user:brgreen
SET fish_color_valid_path:\x2d\x2dunderline
SET fish_greeting:
SET fish_key_bindings:fish_vi_key_bindings
SET fish_pager_color_completion:\x1d
SET fish_pager_color_description:B3A06D\x1eyellow
SET fish_pager_color_prefix:white\x1e\x2d\x2dbold\x1e\x2d\x2dunderline
SET fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan
SET fish_user_paths:/home/marc/\x2efzf/bin

2
.config/fish/fishfile Normal file
View File

@@ -0,0 +1,2 @@
jorgebucaran/fish-bax
oh-my-fish/theme-bobthefish

View File

@@ -0,0 +1,636 @@
function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthefish'
switch "$color_scheme"
case 'user'
__bobthefish_user_color_scheme_deprecated
return
case 'terminal' 'terminal-dark*'
set -l colorfg black
[ "$color_scheme" = 'terminal-dark-white' ]; and set colorfg white
set -x color_initial_segment_exit white red --bold
set -x color_initial_segment_su white green --bold
set -x color_initial_segment_jobs white blue --bold
set -x color_path black white
set -x color_path_basename black white --bold
set -x color_path_nowrite magenta $colorfg
set -x color_path_nowrite_basename magenta $colorfg --bold
set -x color_repo green $colorfg
set -x color_repo_work_tree black $colorfg --bold
set -x color_repo_dirty brred $colorfg
set -x color_repo_staged yellow $colorfg
set -x color_vi_mode_default brblue $colorfg --bold
set -x color_vi_mode_insert brgreen $colorfg --bold
set -x color_vi_mode_visual bryellow $colorfg --bold
set -x color_vagrant brcyan $colorfg
set -x color_k8s magenta white --bold
set -x color_username white black --bold
set -x color_hostname white black
set -x color_rvm brmagenta $colorfg --bold
set -x color_nvm brgreen $colorfg --bold
set -x color_virtualfish brblue $colorfg --bold
set -x color_virtualgo brblue $colorfg --bold
set -x color_desk brblue $colorfg --bold
case 'terminal-light*'
set -l colorfg white
[ "$color_scheme" = 'terminal-light-black' ]; and set colorfg black
set -x color_initial_segment_exit black red --bold
set -x color_initial_segment_su black green --bold
set -x color_initial_segment_jobs black blue --bold
set -x color_path white black
set -x color_path_basename white black --bold
set -x color_path_nowrite magenta $colorfg
set -x color_path_nowrite_basename magenta $colorfg --bold
set -x color_repo green $colorfg
set -x color_repo_work_tree white $colorfg --bold
set -x color_repo_dirty brred $colorfg
set -x color_repo_staged yellow $colorfg
set -x color_vi_mode_default brblue $colorfg --bold
set -x color_vi_mode_insert brgreen $colorfg --bold
set -x color_vi_mode_visual bryellow $colorfg --bold
set -x color_vagrant brcyan $colorfg
set -x color_k8s magenta white --bold
set -x color_username black white --bold
set -x color_hostname black white
set -x color_rvm brmagenta $colorfg --bold
set -x color_nvm brgreen $colorfg --bold
set -x color_virtualfish brblue $colorfg --bold
set -x color_virtualgo brblue $colorfg --bold
set -x color_desk brblue $colorfg --bold
case 'terminal2' 'terminal2-dark*'
set -l colorfg black
[ "$color_scheme" = 'terminal2-dark-white' ]; and set colorfg white
set -x color_initial_segment_exit grey red --bold
set -x color_initial_segment_su grey green --bold
set -x color_initial_segment_jobs grey blue --bold
set -x color_path brgrey white
set -x color_path_basename brgrey white --bold
set -x color_path_nowrite magenta $colorfg
set -x color_path_nowrite_basename magenta $colorfg --bold
set -x color_repo green $colorfg
set -x color_repo_work_tree brgrey $colorfg --bold
set -x color_repo_dirty brred $colorfg
set -x color_repo_staged yellow $colorfg
set -x color_vi_mode_default brblue $colorfg --bold
set -x color_vi_mode_insert brgreen $colorfg --bold
set -x color_vi_mode_visual bryellow $colorfg --bold
set -x color_vagrant brcyan $colorfg
set -x color_k8s magenta white --bold
set -x color_username brgrey white --bold
set -x color_hostname brgrey white
set -x color_rvm brmagenta $colorfg --bold
set -x color_nvm brgreen $colorfg --bold
set -x color_virtualfish brblue $colorfg --bold
set -x color_virtualgo brblue $colorfg --bold
set -x color_desk brblue $colorfg --bold
case 'terminal2-light*'
set -l colorfg white
[ "$color_scheme" = 'terminal2-light-black' ]; and set colorfg black
set -x color_initial_segment_exit brgrey red --bold
set -x color_initial_segment_su brgrey green --bold
set -x color_initial_segment_jobs brgrey blue --bold
set -x color_path grey black
set -x color_path_basename grey black --bold
set -x color_path_nowrite magenta $colorfg
set -x color_path_nowrite_basename magenta $colorfg --bold
set -x color_repo green $colorfg
set -x color_repo_work_tree grey $colorfg --bold
set -x color_repo_dirty brred $colorfg
set -x color_repo_staged yellow $colorfg
set -x color_vi_mode_default brblue $colorfg --bold
set -x color_vi_mode_insert brgreen $colorfg --bold
set -x color_vi_mode_visual bryellow $colorfg --bold
set -x color_vagrant brcyan $colorfg
set -x color_k8s magenta white --bold
set -x color_username grey black --bold
set -x color_hostname grey black
set -x color_rvm brmagenta $colorfg --bold
set -x color_nvm brgreen $colorfg --bold
set -x color_virtualfish brblue $colorfg --bold
set -x color_virtualgo brblue $colorfg --bold
set -x color_desk brblue $colorfg --bold
case 'zenburn'
set -l grey 333333 # a bit darker than normal zenburn grey
set -l red CC9393
set -l green 7F9F7F
set -l yellow E3CEAB
set -l orange DFAF8F
set -l blue 8CD0D3
set -l white DCDCCC
set -x color_initial_segment_exit $white $red --bold
set -x color_initial_segment_su $white $green --bold
set -x color_initial_segment_jobs $white $blue --bold
set -x color_path $grey $white
set -x color_path_basename $grey $white --bold
set -x color_path_nowrite $grey $red
set -x color_path_nowrite_basename $grey $red --bold
set -x color_repo $green $grey
set -x color_repo_work_tree $grey $grey --bold
set -x color_repo_dirty $red $grey
set -x color_repo_staged $yellow $grey
set -x color_vi_mode_default $grey $yellow --bold
set -x color_vi_mode_insert $green $white --bold
set -x color_vi_mode_visual $yellow $grey --bold
set -x color_vagrant $blue $green --bold
set -x color_k8s $green $white --bold
set -x color_username $grey $blue --bold
set -x color_hostname $grey $blue
set -x color_rvm $red $grey --bold
set -x color_nvm $green $white --bold
set -x color_virtualfish $blue $grey --bold
set -x color_virtualgo $blue $grey --bold
set -x color_desk $blue $grey --bold
case 'base16-light'
set -l base00 181818
set -l base01 282828
set -l base02 383838
set -l base03 585858
set -l base04 b8b8b8
set -l base05 d8d8d8
set -l base06 e8e8e8
set -l base07 f8f8f8
set -l base08 ab4642 # red
set -l base09 dc9656 # orange
set -l base0A f7ca88 # yellow
set -l base0B a1b56c # green
set -l base0C 86c1b9 # cyan
set -l base0D 7cafc2 # blue
set -l base0E ba8baf # violet
set -l base0F a16946 # brown
set -l colorfg $base00
set -x color_initial_segment_exit $base02 $base08 --bold
set -x color_initial_segment_su $base02 $base0B --bold
set -x color_initial_segment_jobs $base02 $base0D --bold
set -x color_path $base06 $base02
set -x color_path_basename $base06 $base01 --bold
set -x color_path_nowrite $base06 $base08
set -x color_path_nowrite_basename $base06 $base08 --bold
set -x color_repo $base0B $colorfg
set -x color_repo_work_tree $base06 $colorfg --bold
set -x color_repo_dirty $base08 $colorfg
set -x color_repo_staged $base09 $colorfg
set -x color_vi_mode_default $base04 $colorfg --bold
set -x color_vi_mode_insert $base0B $colorfg --bold
set -x color_vi_mode_visual $base09 $colorfg --bold
set -x color_vagrant $base0C $colorfg --bold
set -x color_k8s $base06 $colorfg --bold
set -x color_username $base02 $base0D --bold
set -x color_hostname $base02 $base0D
set -x color_rvm $base08 $colorfg --bold
set -x color_nvm $base0B $colorfg --bold
set -x color_virtualfish $base0D $colorfg --bold
set -x color_virtualgo $base0D $colorfg --bold
set -x color_desk $base0D $colorfg --bold
case 'base16' 'base16-dark'
set -l base00 181818
set -l base01 282828
set -l base02 383838
set -l base03 585858
set -l base04 b8b8b8
set -l base05 d8d8d8
set -l base06 e8e8e8
set -l base07 f8f8f8
set -l base08 ab4642 # red
set -l base09 dc9656 # orange
set -l base0A f7ca88 # yellow
set -l base0B a1b56c # green
set -l base0C 86c1b9 # cyan
set -l base0D 7cafc2 # blue
set -l base0E ba8baf # violet
set -l base0F a16946 # brown
set -l colorfg $base07
set -x color_initial_segment_exit $base05 $base08 --bold
set -x color_initial_segment_su $base05 $base0B --bold
set -x color_initial_segment_jobs $base05 $base0D --bold
set -x color_path $base02 $base05
set -x color_path_basename $base02 $base06 --bold
set -x color_path_nowrite $base02 $base08
set -x color_path_nowrite_basename $base02 $base08 --bold
set -x color_repo $base0B $colorfg
set -x color_repo_work_tree $base02 $colorfg --bold
set -x color_repo_dirty $base08 $colorfg
set -x color_repo_staged $base09 $colorfg
set -x color_vi_mode_default $base03 $colorfg --bold
set -x color_vi_mode_insert $base0B $colorfg --bold
set -x color_vi_mode_visual $base09 $colorfg --bold
set -x color_vagrant $base0C $colorfg --bold
set -x color_k8s $base0B $colorfg --bold
set -x color_username $base02 $base0D --bold
set -x color_hostname $base02 $base0D
set -x color_rvm $base08 $colorfg --bold
set -x color_nvm $base0B $colorfg --bold
set -x color_virtualfish $base0D $colorfg --bold
set -x color_virtualgo $base0D $colorfg --bold
set -x color_desk $base0D $colorfg --bold
case 'solarized-light'
set -l base03 002b36
set -l base02 073642
set -l base01 586e75
set -l base00 657b83
set -l base0 839496
set -l base1 93a1a1
set -l base2 eee8d5
set -l base3 fdf6e3
set -l yellow b58900
set -l orange cb4b16
set -l red dc322f
set -l magenta d33682
set -l violet 6c71c4
set -l blue 268bd2
set -l cyan 2aa198
set -l green 859900
set colorfg $base03
set -x color_initial_segment_exit $base02 $red --bold
set -x color_initial_segment_su $base02 $green --bold
set -x color_initial_segment_jobs $base02 $blue --bold
set -x color_path $base2 $base00
set -x color_path_basename $base2 $base01 --bold
set -x color_path_nowrite $base2 $orange
set -x color_path_nowrite_basename $base2 $orange --bold
set -x color_repo $green $colorfg
set -x color_repo_work_tree $base2 $colorfg --bold
set -x color_repo_dirty $red $colorfg
set -x color_repo_staged $yellow $colorfg
set -x color_vi_mode_default $blue $colorfg --bold
set -x color_vi_mode_insert $green $colorfg --bold
set -x color_vi_mode_visual $yellow $colorfg --bold
set -x color_vagrant $violet $colorfg --bold
set -x color_k8s $green $colorfg --bold
set -x color_username $base2 $blue --bold
set -x color_hostname $base2 $blue
set -x color_rvm $red $colorfg --bold
set -x color_nvm $green $colorfg --bold
set -x color_virtualfish $cyan $colorfg --bold
set -x color_virtualgo $cyan $colorfg --bold
set -x color_desk $cyan $colorfg --bold
case 'solarized' 'solarized-dark'
set -l base03 002b36
set -l base02 073642
set -l base01 586e75
set -l base00 657b83
set -l base0 839496
set -l base1 93a1a1
set -l base2 eee8d5
set -l base3 fdf6e3
set -l yellow b58900
set -l orange cb4b16
set -l red dc322f
set -l magenta d33682
set -l violet 6c71c4
set -l blue 268bd2
set -l cyan 2aa198
set -l green 859900
set colorfg $base3
set -x color_initial_segment_exit $base2 $red --bold
set -x color_initial_segment_su $base2 $green --bold
set -x color_initial_segment_jobs $base2 $blue --bold
set -x color_path $base02 $base0
set -x color_path_basename $base02 $base1 --bold
set -x color_path_nowrite $base02 $orange
set -x color_path_nowrite_basename $base02 $orange --bold
set -x color_repo $green $colorfg
set -x color_repo_work_tree $base02 $colorfg --bold
set -x color_repo_dirty $red $colorfg
set -x color_repo_staged $yellow $colorfg
set -x color_vi_mode_default $blue $colorfg --bold
set -x color_vi_mode_insert $green $colorfg --bold
set -x color_vi_mode_visual $yellow $colorfg --bold
set -x color_vagrant $violet $colorfg --bold
set -x color_k8s $green $colorfg --bold
set -x color_username $base02 $blue --bold
set -x color_hostname $base02 $blue
set -x color_rvm $red $colorfg --bold
set -x color_nvm $green $colorfg --bold
set -x color_virtualfish $cyan $colorfg --bold
set -x color_virtualgo $cyan $colorfg --bold
set -x color_desk $cyan $colorfg --bold
case 'light'
# light medium dark
# ------ ------ ------
set -l red cc9999 ce000f 660000
set -l green addc10 189303 0c4801
set -l blue 48b4fb 005faf 255e87
set -l orange f6b117 unused 3a2a03
set -l brown bf5e00 803f00 4d2600
set -l grey cccccc 999999 333333
set -l white ffffff
set -l black 000000
set -l ruby_red af0000
set -x color_initial_segment_exit $grey[3] $red[2] --bold
set -x color_initial_segment_su $grey[3] $green[2] --bold
set -x color_initial_segment_jobs $grey[3] $blue[3] --bold
set -x color_path $grey[1] $grey[2]
set -x color_path_basename $grey[1] $grey[3] --bold
set -x color_path_nowrite $red[1] $red[3]
set -x color_path_nowrite_basename $red[1] $red[3] --bold
set -x color_repo $green[1] $green[3]
set -x color_repo_work_tree $grey[1] $white --bold
set -x color_repo_dirty $red[2] $white
set -x color_repo_staged $orange[1] $orange[3]
set -x color_vi_mode_default $grey[2] $grey[3] --bold
set -x color_vi_mode_insert $green[2] $grey[3] --bold
set -x color_vi_mode_visual $orange[1] $orange[3] --bold
set -x color_vagrant $blue[1] $white --bold
set -x color_k8s $green[1] $colorfg --bold
set -x color_username $grey[1] $blue[3] --bold
set -x color_hostname $grey[1] $blue[3]
set -x color_rvm $ruby_red $grey[1] --bold
set -x color_nvm $green $grey[1] --bold
set -x color_virtualfish $blue[2] $grey[1] --bold
set -x color_virtualgo $blue[2] $grey[1] --bold
set -x color_desk $blue[2] $grey[1] --bold
case 'gruvbox'
# light medium dark darkest
# ------ ------ ------ -------
set -l red fb4934 cc241d
set -l green b8bb26 98971a
set -l yellow fabd2f d79921
set -l aqua 8ec07c 689d6a
set -l blue 83a598 458588
set -l grey cccccc 999999 333333
set -l fg fbf1c7 ebdbb2 d5c4a1 a89984
set -l bg 504945 282828
set -x color_initial_segment_exit $fg[1] $red[2] --bold
set -x color_initial_segment_su $fg[1] $green[2] --bold
set -x color_initial_segment_jobs $fg[1] $aqua[2] --bold
set -x color_path $bg[1] $fg[2]
set -x color_path_basename $bg[1] $fg[2] --bold
set -x color_path_nowrite $red[1] $fg[2]
set -x color_path_nowrite_basename $red[1] $fg[2] --bold
set -x color_repo $green[2] $bg[1]
set -x color_repo_work_tree $bg[1] $fg[2] --bold
set -x color_repo_dirty $red[2] $fg[2]
set -x color_repo_staged $yellow[1] $bg[1]
set -x color_vi_mode_default $fg[4] $bg[2] --bold
set -x color_vi_mode_insert $blue[1] $bg[2] --bold
set -x color_vi_mode_visual $yellow[1] $bg[2] --bold
set -x color_vagrant $blue[2] $fg[2] --bold
set -x color_k8s $green[2] $fg[2] --bold
set -x color_username $fg[3] $blue[2] --bold
set -x color_hostname $fg[3] $blue[2]
set -x color_rvm $red[2] $fg[2] --bold
set -x color_nvm $green[1] $fg[2] --bold
set -x color_virtualfish $blue[2] $fg[2] --bold
set -x color_virtualgo $blue[2] $fg[2] --bold
set -x color_desk $blue[2] $fg[2] --bold
case 'dracula' # https://draculatheme.com
set -l bg 282a36
set -l current_line 44475a
set -l selection 44475a
set -l fg f8f8f2
set -l comment 6272a4
set -l cyan 8be9fd
set -l green 50fa7b
set -l orange ffb86c
set -l pink ff79c6
set -l purple bd93f9
set -l red ff5555
set -l yellow f1fa8c
set -x color_initial_segment_exit $fg $red --bold
set -x color_initial_segment_su $fg $purple --bold
set -x color_initial_segment_jobs $fg $comment --bold
set -x color_path $selection $fg
set -x color_path_basename $selection $fg --bold
set -x color_path_nowrite $selection $red
set -x color_path_nowrite_basename $selection $red --bold
set -x color_repo $green $bg
set -x color_repo_work_tree $selection $fg --bold
set -x color_repo_dirty $red $bg
set -x color_repo_staged $yellow $bg
set -x color_vi_mode_default $bg $yellow --bold
set -x color_vi_mode_insert $green $bg --bold
set -x color_vi_mode_visual $orange $bg --bold
set -x color_vagrant $pink $bg --bold
set -x color_k8s $green $fg --bold
set -x color_username $selection $cyan --bold
set -x color_hostname $selection $cyan
set -x color_rvm $red $bg --bold
set -x color_nvm $green $bg --bold
set -x color_virtualfish $comment $bg --bold
set -x color_virtualgo $cyan $bg --bold
set -x color_desk $comment $bg --bold
case 'nord'
set -l base00 2E3440
set -l base01 3B4252
set -l base02 434C5E
set -l base03 4C566A
set -l base04 D8DEE9
set -l base05 E5E9F0
set -l base06 ECEFF4
set -l base07 8FBCBB
set -l base08 88C0D0
set -l base09 81A1C1
set -l base0A 5E81AC
set -l base0B BF616A
set -l base0C D08770
set -l base0D EBCB8B
set -l base0E A3BE8C
set -l base0F B48EAD
set -l colorfg $base00
set -x color_initial_segment_exit $base05 $base08 --bold
set -x color_initial_segment_su $base05 $base0B --bold
set -x color_initial_segment_jobs $base08 $base0D --bold
set -x color_path $base02 $base05
set -x color_path_basename $base02 $base06 --bold
set -x color_path_nowrite $base02 $base08
set -x color_path_nowrite_basename $base02 $base08 --bold
set -x color_repo $base0E $colorfg
set -x color_repo_work_tree $base02 $colorfg --bold
set -x color_repo_dirty $base0B $colorfg
set -x color_repo_staged $base0D $colorfg
set -x color_vi_mode_default $base08 $colorfg --bold
set -x color_vi_mode_insert $base06 $colorfg --bold
set -x color_vi_mode_visual $base07 $colorfg --bold
set -x color_vagrant $base02 $colorfg --bold
set -x color_k8s $base02 $colorfg --bold
set -x color_username $base02 $base0D --bold
set -x color_hostname $base02 $base0D
set -x color_rvm $base09 $colorfg --bold
set -x color_nvm $base09 $colorfg --bold
set -x color_virtualfish $base09 $colorfg --bold
set -x color_virtualgo $base09 $colorfg --bold
set -x color_desk $base09 $colorfg --bold
case '*' # default dark theme
# light medium dark
# ------ ------ ------
set -l red cc9999 ce000f 660000
set -l green addc10 189303 0c4801
set -l blue 48b4fb 005faf 255e87
set -l orange f6b117 unused 3a2a03
set -l brown bf5e00 803f00 4d2600
set -l grey cccccc 999999 333333
set -l white ffffff
set -l black 000000
set -l ruby_red af0000
set -l go_blue 00d7d7
set -x color_initial_segment_exit $white $red[2] --bold
set -x color_initial_segment_su $white $green[2] --bold
set -x color_initial_segment_jobs $white $blue[3] --bold
set -x color_path $grey[3] $grey[2]
set -x color_path_basename $grey[3] $white --bold
set -x color_path_nowrite $red[3] $red[1]
set -x color_path_nowrite_basename $red[3] $red[1] --bold
set -x color_repo $green[1] $green[3]
set -x color_repo_work_tree $grey[3] $white --bold
set -x color_repo_dirty $red[2] $white
set -x color_repo_staged $orange[1] $orange[3]
set -x color_vi_mode_default $grey[2] $grey[3] --bold
set -x color_vi_mode_insert $green[2] $grey[3] --bold
set -x color_vi_mode_visual $orange[1] $orange[3] --bold
set -x color_vagrant $blue[1] $white --bold
set -x color_k8s $green[2] $white --bold
set -x color_username $grey[1] $blue[3] --bold
set -x color_hostname $grey[1] $blue[3]
set -x color_rvm $ruby_red $grey[1] --bold
set -x color_nvm $green[1] $white --bold
set -x color_virtualfish $blue[2] $grey[1] --bold
set -x color_virtualgo $go_blue $black --bold
set -x color_desk $blue[2] $grey[1] --bold
end
end
function __bobthefish_user_color_scheme_deprecated
set -q __color_initial_segment_exit; or set -l __color_initial_segment_exit ffffff ce000f --bold
set -q __color_initial_segment_su; or set -l __color_initial_segment_su ffffff 189303 --bold
set -q __color_initial_segment_jobs; or set -l __color_initial_segment_jobs ffffff 255e87 --bold
set -q __color_path; or set -l __color_path 333333 999999
set -q __color_path_basename; or set -l __color_path_basename 333333 ffffff --bold
set -q __color_path_nowrite; or set -l __color_path_nowrite 660000 cc9999
set -q __color_path_nowrite_basename; or set -l __color_path_nowrite_basename 660000 cc9999 --bold
set -q __color_repo; or set -l __color_repo addc10 0c4801
set -q __color_repo_work_tree; or set -l __color_repo_work_tree 333333 ffffff --bold
set -q __color_repo_dirty; or set -l __color_repo_dirty ce000f ffffff
set -q __color_repo_staged; or set -l __color_repo_staged f6b117 3a2a03
set -q __color_vi_mode_default; or set -l __color_vi_mode_default 999999 333333 --bold
set -q __color_vi_mode_insert; or set -l __color_vi_mode_insert 189303 333333 --bold
set -q __color_vi_mode_visual; or set -l __color_vi_mode_visual f6b117 3a2a03 --bold
set -q __color_vagrant; or set -l __color_vagrant 48b4fb ffffff --bold
set -q __color_username; or set -l __color_username cccccc 255e87 --bold
set -q __color_hostname; or set -l __color_hostname cccccc 255e87
set -q __color_rvm; or set -l __color_rvm af0000 cccccc --bold
set -q __color_virtualfish; or set -l __color_virtualfish 005faf cccccc --bold
set -q __color_virtualgo; or set -l __color_virtualgo 005faf cccccc --bold
set -q __color_desk; or set -l __color_desk 005faf cccccc --bold
set_color black -b red --bold
echo "The 'user' color scheme is deprecated."
set_color normal
set_color black -b red
echo "To define a custom color scheme, create a 'bobthefish_colors' function:"
set_color normal
echo
echo "function bobthefish_colors -S -d 'Define a custom bobthefish color scheme'
# optionally include a base color scheme...
___bobthefish_colors default
# then override everything you want! note that these must be defined with `set -x`
set -x color_initial_segment_exit $__color_initial_segment_exit
set -x color_initial_segment_su $__color_initial_segment_su
set -x color_initial_segment_jobs $__color_initial_segment_jobs
set -x color_path $__color_path
set -x color_path_basename $__color_path_basename
set -x color_path_nowrite $__color_path_nowrite
set -x color_path_nowrite_basename $__color_path_nowrite_basename
set -x color_repo $__color_repo
set -x color_repo_work_tree $__color_repo_work_tree
set -x color_repo_dirty $__color_repo_dirty
set -x color_repo_staged $__color_repo_staged
set -x color_vi_mode_default $__color_vi_mode_default
set -x color_vi_mode_insert $__color_vi_mode_insert
set -x color_vi_mode_visual $__color_vi_mode_visual
set -x color_vagrant $__color_vagrant
set -x color_username $__color_username
set -x color_hostname $__color_hostname
set -x color_rvm $__color_rvm
set -x color_virtualfish $__color_virtualfish
set -x color_virtualgo $__color_virtualgo
set -x color_desk $__color_desk
end"
echo
end

View File

@@ -0,0 +1,3 @@
function __bobthefish_display_colors -d 'Print example prompts using the current color scheme'
bobthefish_display_colors
end

View File

@@ -0,0 +1,93 @@
function __bobthefish_glyphs -S -d 'Define glyphs used by bobthefish'
# Powerline glyphs
set -x branch_glyph \uE0A0
set -x right_black_arrow_glyph \uE0B0
set -x right_arrow_glyph \uE0B1
set -x left_black_arrow_glyph \uE0B2
set -x left_arrow_glyph \uE0B3
# Additional glyphs
set -x detached_glyph \u27A6
set -x tag_glyph \u2302
set -x nonzero_exit_glyph '! '
set -x superuser_glyph '$ '
set -x bg_job_glyph '% '
set -x hg_glyph \u263F
# Python glyphs
set -x superscript_glyph \u00B9 \u00B2 \u00B3
set -x virtualenv_glyph 'py' # \u25F0
set -x pypy_glyph \u1D56
set -x ruby_glyph ''
set -x go_glyph ''
# Desk glyphs
set -x desk_glyph \u25F2
# Kubernetes glyphs
set -x k8s_glyph \u2388 # '⎈'
# Vagrant glyphs
set -x vagrant_running_glyph \u2191 # ↑ 'running'
set -x vagrant_poweroff_glyph \u2193 # ↓ 'poweroff'
set -x vagrant_aborted_glyph \u2715 # ✕ 'aborted'
set -x vagrant_saved_glyph \u21E1 # ⇡ 'saved'
set -x vagrant_stopping_glyph \u21E3 # ⇣ 'stopping'
set -x vagrant_unknown_glyph '!' # strange cases
# Git glyphs
set -x git_dirty_glyph '*'
set -x git_staged_glyph '~'
set -x git_stashed_glyph '$'
set -x git_untracked_glyph '…'
set -x git_ahead_glyph \u2191 # '↑'
set -x git_behind_glyph \u2193 # '↓'
set -x git_plus_glyph '+'
set -x git_minus_glyph '-'
set -x git_plus_minus_glyph '±'
# Disable Powerline fonts (unless we're using nerd fonts instead)
if [ "$theme_powerline_fonts" = "no" -a "$theme_nerd_fonts" != "yes" ]
set branch_glyph \u2387
set right_black_arrow_glyph ''
set right_arrow_glyph ''
set left_black_arrow_glyph ''
set left_arrow_glyph ''
end
# Use prettier Nerd Fonts glyphs
if [ "$theme_nerd_fonts" = "yes" ]
set branch_glyph \uF418
set detached_glyph \uF417
set tag_glyph \uF412
set virtualenv_glyph \uE73C ' '
set ruby_glyph \uE791 ' '
set go_glyph \uE626 ' '
set node_glyph \uE718 ' '
set vagrant_running_glyph \uF431 # ↑ 'running'
set vagrant_poweroff_glyph \uF433 # ↓ 'poweroff'
set vagrant_aborted_glyph \uF468 # ✕ 'aborted'
set vagrant_unknown_glyph \uF421 # strange cases
set git_dirty_glyph \uF448 '' # nf-oct-pencil
set git_staged_glyph \uF0C7 '' # nf-fa-save
set git_stashed_glyph \uF0C6 '' # nf-fa-paperclip
set git_untracked_glyph \uF128 '' # nf-fa-question
# set git_untracked_glyph \uF141 '' # nf-fa-ellipsis_h
set git_ahead_glyph \uF47B # nf-oct-chevron_up
set git_behind_glyph \uF47C # nf-oct-chevron_down
set git_plus_glyph \uF0DE # fa-sort-asc
set git_minus_glyph \uF0DD # fa-sort-desc
set git_plus_minus_glyph \uF0DC # fa-sort
end
# Avoid ambiguous glyphs
if [ "$theme_avoid_ambiguous_glyphs" = "yes" ]
set git_untracked_glyph '...'
end
end

View File

@@ -0,0 +1,46 @@
set -g bax_version 1.0.0
complete -xc bax -n __fish_use_subcommand -a --help -d "Show usage help"
complete -xc bax -n __fish_use_subcommand -a --version -d "$bax_version"
function bax
switch "$argv"
case {,-}-h{elp,} ""
echo "usage: bax <bash commands> Run a bash command"
echo " bax --help Show this help"
echo " bax --version Show the current version"
case {,-}-v{ersion,}
echo "bax version $bax_version"
case \*
set -l delim "@@@@bax@@@@"
command bash -c "
$argv
status=\$?
[ \$status -eq 0 ] && echo $delim && alias && echo $delim && command awk '
BEGIN {
for (k in ENVIRON)
if (gsub(/\n/, \"\\\n\", ENVIRON[k]) >= 0)
print k, ENVIRON[k]
}
' || echo $delim \$status
" | command awk -v delim="$delim" '
$0 != delim || !++i {
if ($1 == delim) exit $2
else if (i < 2) print (i ? $0 : gsub(/\$/, "\\\$") >= 0 ? "echo \"" $0 "\"" : "")
else env[$1] = (gsub(/\\\n/, "\n") >= 0 ? substr($0, length($1) + 2) : "")
}
END {
for (k in env)
if (len++ && k !~ /^(_|SHLVL|PS1|XPC_SERVICE_NAME|AWK(LIB)?PATH)$|^BASH_FUNC/\
&& !(k in ENVIRON && ENVIRON[k] == env[k]))
print (\
k == "PATH" && gsub(/:/, "\" \"", env[k]) >= 0\
? "set PATH \"" env[k] "\"" : k == "PWD"\
? "cd \"" env[k] "\"" : "set -gx " k " \"" env[k] "\""\
)
if (!len) print "exit " $2
else for (k in ENVIRON) if (!(k in env)) print "set -e " k
}
' | source
end
end

View File

@@ -0,0 +1,135 @@
function bobthefish_display_colors -a color_scheme -d 'Print example prompt color schemes'
set -l color_schemes default light \
solarized solarized-light \
base16 base16-light \
gruvbox zenburn \
dracula \
terminal terminal-dark-white \
terminal-light terminal-light-black \
terminal2 terminal2-dark-white \
terminal2-light terminal2-light-black
switch "$color_scheme"
case '--all'
for scheme in $color_schemes
echo
echo "$scheme:"
bobthefish_display_colors $scheme
end
return
case $color_schemes
__bobthefish_colors $color_scheme
case ''
[ -n "$theme_color_scheme" ]
and echo "$theme_color_scheme:"
__bobthefish_colors $theme_color_scheme
type -q bobthefish_colors
and bobthefish_colors
case '*'
echo 'usage: bobthefish_display_colors [--all] [color_scheme]'
return
end
__bobthefish_glyphs
echo
set_color normal
__bobthefish_start_segment $color_initial_segment_exit
echo -n exit $nonzero_exit_glyph
set_color -b $color_initial_segment_su
echo -n su $superuser_glyph
set_color -b $color_initial_segment_jobs
echo -n jobs $bg_job_glyph
__bobthefish_finish_segments
set_color normal
echo -n "(<- initial_segment)"
echo
__bobthefish_start_segment $color_path
echo -n /color/path/
set_color -b $color_path_basename
echo -ns basename ' '
__bobthefish_finish_segments
echo
__bobthefish_start_segment $color_path_nowrite
echo -n /color/path/nowrite/
set_color -b $color_path_nowrite_basename
echo -ns basename ' '
__bobthefish_finish_segments
echo
__bobthefish_start_segment $color_path
echo -n /color/path/
set_color -b $color_path_basename
echo -ns basename ' '
__bobthefish_start_segment $color_repo
echo -n "$branch_glyph repo $git_stashed_glyph "
__bobthefish_finish_segments
echo
__bobthefish_start_segment $color_path
echo -n /color/path/
set_color -b $color_path_basename
echo -ns basename ' '
__bobthefish_start_segment $color_repo_dirty
echo -n "$tag_glyph repo_dirty $git_dirty_glyph "
__bobthefish_finish_segments
echo
__bobthefish_start_segment $color_path
echo -n /color/path/
set_color -b $color_path_basename
echo -ns basename ' '
__bobthefish_start_segment $color_repo_staged
echo -n "$detached_glyph repo_staged $git_staged_glyph "
__bobthefish_finish_segments
echo
__bobthefish_start_segment $color_vi_mode_default
echo -ns vi_mode_default ' '
__bobthefish_finish_segments
__bobthefish_start_segment $color_vi_mode_insert
echo -ns vi_mode_insert ' '
__bobthefish_finish_segments
__bobthefish_start_segment $color_vi_mode_visual
echo -ns vi_mode_visual ' '
__bobthefish_finish_segments
echo
__bobthefish_start_segment $color_vagrant
echo -ns $vagrant_running_glyph ' ' vagrant ' '
__bobthefish_finish_segments
echo
__bobthefish_start_segment $color_username
echo -n username
set_color normal
set_color -b $color_hostname[1] $color_hostname[2..-1]
echo -ns @hostname ' '
__bobthefish_finish_segments
echo
__bobthefish_start_segment $color_rvm
echo -ns $ruby_glyph rvm ' '
__bobthefish_finish_segments
__bobthefish_start_segment $color_virtualfish
echo -ns $virtualenv_glyph virtualfish ' '
__bobthefish_finish_segments
__bobthefish_start_segment $color_virtualgo
echo -ns $go_glyph virtualgo ' '
__bobthefish_finish_segments
__bobthefish_start_segment $color_desk
echo -ns $desk_glyph desk ' '
__bobthefish_finish_segments
echo -e "\n"
end

View File

@@ -0,0 +1,10 @@
function fish_greeting -d "What's up, fish?"
set_color $fish_color_autosuggestion
uname -nmsr
# TODO: `command -q -s` only works on fish 2.5+, so hold off on that for now
command -s uptime >/dev/null
and command uptime
set_color normal
end

View File

@@ -0,0 +1,9 @@
# This is handled inside fish_mode_prompt (see `__bobthefish_prompt_vi`)
#
# If you want to override this with your own mode prompt, disable bobthefish's
# built-in mode prompt in your fish config:
#
# set -g theme_display_vi no
function fish_mode_prompt
end

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,79 @@
# You can override some default right prompt options in your config.fish:
# set -g theme_date_format "+%a %H:%M"
function __bobthefish_cmd_duration -S -d 'Show command duration'
[ "$theme_display_cmd_duration" = "no" ]
and return
[ -z "$CMD_DURATION" -o "$CMD_DURATION" -lt 100 ]
and return
if [ "$CMD_DURATION" -lt 5000 ]
echo -ns $CMD_DURATION 'ms'
else if [ "$CMD_DURATION" -lt 60000 ]
__bobthefish_pretty_ms $CMD_DURATION s
else if [ "$CMD_DURATION" -lt 3600000 ]
set_color $fish_color_error
__bobthefish_pretty_ms $CMD_DURATION m
else
set_color $fish_color_error
__bobthefish_pretty_ms $CMD_DURATION h
end
set_color $fish_color_normal
set_color $fish_color_autosuggestion
[ "$theme_display_date" = "no" ]
or echo -ns ' ' $__bobthefish_left_arrow_glyph
end
function __bobthefish_pretty_ms -S -a ms -a interval -d 'Millisecond formatting for humans'
set -l interval_ms
set -l scale 1
switch $interval
case s
set interval_ms 1000
case m
set interval_ms 60000
case h
set interval_ms 3600000
set scale 2
end
switch $FISH_VERSION
case 2.0.\* 2.1.\* 2.2.\* 2.3.\*
# Fish 2.3 and lower doesn't know about the -s argument to math.
math "scale=$scale;$ms/$interval_ms" | string replace -r '\\.?0*$' $interval
case 2.\*
# Fish 2.x always returned a float when given the -s argument.
math -s$scale "$ms/$interval_ms" | string replace -r '\\.?0*$' $interval
case \*
math -s$scale "$ms/$interval_ms"
echo -ns $interval
end
end
function __bobthefish_timestamp -S -d 'Show the current timestamp'
[ "$theme_display_date" = "no" ]
and return
set -q theme_date_format
or set -l theme_date_format "+%c"
echo -n ' '
date $theme_date_format
end
function fish_right_prompt -d 'bobthefish is all about the right prompt'
set -l __bobthefish_left_arrow_glyph \uE0B3
if [ "$theme_powerline_fonts" = "no" ]
set __bobthefish_left_arrow_glyph '<'
end
set_color $fish_color_autosuggestion
__bobthefish_cmd_duration
__bobthefish_timestamp
set_color normal
end

View File

@@ -0,0 +1,34 @@
# You can override some default title options in your config.fish:
# set -g theme_title_display_process no
# set -g theme_title_display_path no
# set -g theme_title_display_user yes
# set -g theme_title_use_abbreviated_path no
function __bobthefish_title_user -S -d 'Display actual user if different from $default_user'
if [ "$theme_title_display_user" = 'yes' ]
if [ "$USER" != "$default_user" -o -n "$SSH_CLIENT" ]
set -l IFS .
hostname | read -l hostname __
echo -ns (whoami) '@' $hostname ' '
end
end
end
function fish_title
__bobthefish_title_user
if [ "$theme_title_display_process" = 'yes' ]
echo $_
[ "$theme_title_display_path" != 'no' ]
and echo ' '
end
if [ "$theme_title_display_path" != 'no' ]
if [ "$theme_title_use_abbreviated_path" = 'no' ]
echo $PWD
else
prompt_pwd
end
end
end

View File

@@ -0,0 +1,3 @@
function fish_user_key_bindings
fzf_key_bindings
end

View File

@@ -0,0 +1,435 @@
set -g fisher_version 3.2.10
function fisher -a cmd -d "fish package manager"
set -q XDG_CACHE_HOME; or set XDG_CACHE_HOME ~/.cache
set -q XDG_CONFIG_HOME; or set XDG_CONFIG_HOME ~/.config
set -g fish_config $XDG_CONFIG_HOME/fish
set -g fisher_cache $XDG_CACHE_HOME/fisher
set -g fisher_config $XDG_CONFIG_HOME/fisher
set -q fisher_path; or set -g fisher_path $fish_config
set -g fishfile $fish_config/fishfile
for path in {$fish_config,$fisher_path}/{functions,completions,conf.d} $fisher_cache
if test ! -d $path
command mkdir -p $path
end
end
if test ! -e $fisher_path/completions/fisher.fish
echo "fisher complete" >$fisher_path/completions/fisher.fish
_fisher_complete
end
if test -e $fisher_path/conf.d/fisher.fish
switch "$version"
case \*-\*
command rm -f $fisher_path/conf.d/fisher.fish
case 2\*
case \*
command rm -f $fisher_path/conf.d/fisher.fish
end
else
switch "$version"
case \*-\*
case 2\*
echo "fisher copy-user-key-bindings" >$fisher_path/conf.d/fisher.fish
end
end
# 2019-10-22: temp code, migrates fishfile from old path back to $fish_config
if test -e "$fisher_path/fishfile"; and test ! -e "$fishfile"
command mv -f "$fisher_path/fishfile" "$fishfile"
end
switch "$cmd"
case {,self-}complete
_fisher_complete
case copy-user-key-bindings
_fisher_copy_user_key_bindings
case ls
set -e argv[1]
if test -s "$fishfile"
set -l file (_fisher_fmt <$fishfile | _fisher_parse -R | command sed "s|@.*||")
_fisher_ls | _fisher_fmt | command awk -v FILE="$file" "
BEGIN { for (n = split(FILE, f); ++i <= n;) file[f[i]] } \$0 in file && /$argv[1]/
" | command sed "s|^$HOME|~|"
end
case self-update
_fisher_self_update (status -f)
case self-uninstall
_fisher_self_uninstall
case {,-}-v{ersion,}
echo "fisher version $fisher_version" (status -f | command sed "s|^$HOME|~|")
case {,-}-h{elp,}
_fisher_help
case ""
_fisher_commit --
case add rm
if not isatty
while read -l arg
set argv $argv $arg
end
end
if test (count $argv) = 1
echo "fisher: invalid number of arguments" >&2
_fisher_help >&2
return 1
end
_fisher_commit $argv
case \*
echo "fisher: unknown flag or command \"$cmd\"" >&2
_fisher_help >&2
return 1
end
end
function _fisher_complete
complete -ec fisher
complete -xc fisher -n __fish_use_subcommand -a add -d "Add packages"
complete -xc fisher -n __fish_use_subcommand -a rm -d "Remove packages"
complete -xc fisher -n __fish_use_subcommand -a ls -d "List installed packages matching REGEX"
complete -xc fisher -n __fish_use_subcommand -a --help -d "Show usage help"
complete -xc fisher -n __fish_use_subcommand -a --version -d "$fisher_version"
complete -xc fisher -n __fish_use_subcommand -a self-update -d "Update to the latest version"
for pkg in (fisher ls)
complete -xc fisher -n "__fish_seen_subcommand_from rm" -a $pkg
end
end
function _fisher_copy_user_key_bindings
if functions -q fish_user_key_bindings
functions -c fish_user_key_bindings fish_user_key_bindings_copy
end
function fish_user_key_bindings
for file in $fisher_path/conf.d/*_key_bindings.fish
source $file >/dev/null 2>/dev/null
end
if functions -q fish_user_key_bindings_copy
fish_user_key_bindings_copy
end
end
end
function _fisher_ls
for pkg in $fisher_config/*/*/*
command readlink $pkg; or echo $pkg
end
end
function _fisher_fmt
command sed "s|^[[:space:]]*||;s|^$fisher_config/||;s|^~|$HOME|;s|^\.\/*|$PWD/|;s|^https*:/*||;s|^github\.com/||;s|/*\$||"
end
function _fisher_help
echo "usage: fisher add <package...> Add packages"
echo " fisher rm <package...> Remove packages"
echo " fisher Update all packages"
echo " fisher ls [<regex>] List installed packages matching <regex>"
echo " fisher --help Show this help"
echo " fisher --version Show the current version"
echo " fisher self-update Update to the latest version"
echo " fisher self-uninstall Uninstall from your system"
echo "examples:"
echo " fisher add jethrokuan/z rafaelrinaldi/pure"
echo " fisher add gitlab.com/foo/bar@v2"
echo " fisher add ~/path/to/local/pkg"
echo " fisher add <file"
echo " fisher rm rafaelrinaldi/pure"
echo " fisher ls | fisher rm"
echo " fisher ls fish-\*"
end
function _fisher_self_update -a file
set -l url "https://raw.githubusercontent.com/jorgebucaran/fisher/master/fisher.fish"
echo "fetching $url" >&2
command curl -s "$url?nocache" >$file.
set -l next_version (command awk '{ print $4 } { exit }' <$file.)
switch "$next_version"
case "" $fisher_version
command rm -f $file.
if test -z "$next_version"
echo "fisher: cannot update fisher -- are you offline?" >&2
return 1
end
echo "fisher is already up-to-date" >&2
case \*
echo "linking $file" | command sed "s|$HOME|~|" >&2
command mv -f $file. $file
source $file
echo "updated to fisher $fisher_version -- hooray!" >&2
_fisher_complete
end
end
function _fisher_self_uninstall
for pkg in (_fisher_ls)
_fisher_rm $pkg
end
for file in $fisher_cache $fisher_config $fisher_path/{functions,completions,conf.d}/fisher.fish $fishfile
echo "removing $file"
command rm -Rf $file 2>/dev/null
end | command sed "s|$HOME|~|" >&2
for name in (set -n | command awk '/^fisher_/')
set -e "$name"
end
functions -e (functions -a | command awk '/^_fisher/') fisher
complete -c fisher --erase
end
function _fisher_commit -a cmd
set -e argv[1]
set -l elapsed (_fisher_now)
if test ! -e "$fishfile"
command touch $fishfile
echo "created new fishfile in $fishfile" | command sed "s|$HOME|~|" >&2
end
set -l old_pkgs (_fisher_ls | _fisher_fmt)
for pkg in (_fisher_ls)
_fisher_rm $pkg
end
command rm -Rf $fisher_config
command mkdir -p $fisher_config
set -l next_pkgs (_fisher_fmt <$fishfile | _fisher_parse -R $cmd (printf "%s\n" $argv | _fisher_fmt))
set -l actual_pkgs (_fisher_fetch $next_pkgs)
set -l updated_pkgs
for pkg in $old_pkgs
if contains -- $pkg $actual_pkgs
set updated_pkgs $updated_pkgs $pkg
end
end
if test -z "$actual_pkgs$updated_pkgs$old_pkgs$next_pkgs"
echo "fisher: nothing to commit -- try adding some packages" >&2
return 1
end
set -l out_pkgs
if test "$cmd" = "rm"
set out_pkgs $next_pkgs
else
for pkg in $next_pkgs
if contains -- (echo $pkg | command sed "s|@.*||") $actual_pkgs
set out_pkgs $out_pkgs $pkg
end
end
end
printf "%s\n" (_fisher_fmt <$fishfile | _fisher_parse -W $cmd $out_pkgs | command sed "s|^$HOME|~|") >$fishfile
_fisher_complete
command awk -v A=(count $actual_pkgs) -v U=(count $updated_pkgs) -v O=(count $old_pkgs) -v E=(_fisher_now $elapsed) '
BEGIN {
res = fmt("removed", O - U, fmt("updated", U, fmt("added", A - U)))
printf((res ? res : "done") " in %.2fs\n", E / 1000)
}
function fmt(action, n, s) {
return n ? (s ? s ", " : s) action " " n " package" (n > 1 ? "s" : "") : s
}
' >&2
end
function _fisher_parse -a mode cmd
set -e argv[1..2]
command awk -v FS="[[:space:]]*#+" -v MODE="$mode" -v CMD="$cmd" -v ARGSTR="$argv" '
BEGIN {
for (n = split(ARGSTR, a, " "); i++ < n;) pkgs[getkey(a[i])] = a[i]
}
!NF { next } { k = getkey($1) }
MODE == "-R" && !(k in pkgs) && $0 = $1
MODE == "-W" && (/^#/ || k in pkgs || CMD != "rm") { print pkgs[k] (sub($1, "") ? $0 : "") }
MODE == "-W" || CMD == "rm" { delete pkgs[k] }
END {
for (k in pkgs) {
if (CMD != "rm" || MODE == "-W") print pkgs[k]
else print "fisher: cannot remove \""k"\" -- package is not in fishfile" > "/dev/stderr"
}
}
function getkey(s, a) {
return (split(s, a, /@+|:/) > 2) ? a[2]"/"a[1]"/"a[3] : a[1]
}
'
end
function _fisher_fetch
set -l pkg_jobs
set -l out_pkgs
set -l next_pkgs
set -l local_pkgs
set -q fisher_user_api_token; and set -l curl_opts -u $fisher_user_api_token
for pkg in $argv
switch $pkg
case \~\* /\*
set -l path (echo "$pkg" | command sed "s|^~|$HOME|")
if test -e "$path"
set local_pkgs $local_pkgs $path
else
echo "fisher: cannot add \"$pkg\" -- is this a valid file?" >&2
end
continue
end
command awk -v PKG="$pkg" -v FS=/ '
BEGIN {
if (split(PKG, tmp, /@+|:/) > 2) {
if (tmp[4]) sub("@"tmp[4], "", PKG)
print PKG "\t" tmp[2]"/"tmp[1]"/"tmp[3] "\t" (tmp[4] ? tmp[4] : "master")
} else {
pkg = split(PKG, _, "/") <= 2 ? "github.com/"tmp[1] : tmp[1]
tag = tmp[2] ? tmp[2] : "master"
print (\
pkg ~ /^github/ ? "https://codeload."pkg"/tar.gz/"tag : \
pkg ~ /^gitlab/ ? "https://"pkg"/-/archive/"tag"/"tmp[split(pkg, tmp, "/")]"-"tag".tar.gz" : \
pkg ~ /^bitbucket/ ? "https://"pkg"/get/"tag".tar.gz" : pkg \
) "\t" pkg
}
}
' | read -l url pkg branch
if test ! -d "$fisher_config/$pkg"
fish -c "
echo fetching $url >&2
command mkdir -p $fisher_config/$pkg $fisher_cache/(command dirname $pkg)
if test ! -z \"$branch\"
command git clone $url $fisher_config/$pkg --branch $branch --depth 1 2>/dev/null
or echo fisher: cannot clone \"$url\" -- is this a valid url\? >&2
else if command curl $curl_opts -Ss -w \"\" $url 2>&1 | command tar -xzf- -C $fisher_config/$pkg 2>/dev/null
command rm -Rf $fisher_cache/$pkg
command mv -f $fisher_config/$pkg/* $fisher_cache/$pkg
command rm -Rf $fisher_config/$pkg
command cp -Rf {$fisher_cache,$fisher_config}/$pkg
else if test -d \"$fisher_cache/$pkg\"
echo fisher: cannot connect to server -- looking in \"$fisher_cache/$pkg\" | command sed 's|$HOME|~|' >&2
command cp -Rf $fisher_cache/$pkg $fisher_config/$pkg/..
else
command rm -Rf $fisher_config/$pkg
echo fisher: cannot add \"$pkg\" -- is this a valid package\? >&2
end
" >/dev/null &
set pkg_jobs $pkg_jobs (_fisher_jobs --last)
set next_pkgs $next_pkgs "$fisher_config/$pkg"
end
end
if set -q pkg_jobs[1]
while for job in $pkg_jobs
contains -- $job (_fisher_jobs); and break
end
end
for pkg in $next_pkgs
if test -d "$pkg"
set out_pkgs $out_pkgs $pkg
_fisher_add $pkg
end
end
end
set -l local_prefix $fisher_config/local/$USER
if test ! -d "$local_prefix"
command mkdir -p $local_prefix
end
for pkg in $local_pkgs
set -l target $local_prefix/(command basename $pkg)
if test ! -L "$target"
command ln -sf $pkg $target
set out_pkgs $out_pkgs $pkg
_fisher_add $pkg --link
end
end
if set -q out_pkgs[1]
_fisher_fetch (
for pkg in $out_pkgs
if test -s "$pkg/fishfile"
_fisher_fmt <$pkg/fishfile | _fisher_parse -R
end
end)
printf "%s\n" $out_pkgs | _fisher_fmt
end
end
function _fisher_add -a pkg opts
for src in $pkg/{functions,completions,conf.d}/**.* $pkg/*.fish
set -l target (command basename $src)
switch $src
case $pkg/conf.d\*
set target $fisher_path/conf.d/$target
case $pkg/completions\*
set target $fisher_path/completions/$target
case $pkg/{functions,}\*
switch $target
case uninstall.fish
continue
case {init,key_bindings}.fish
set target $fisher_path/conf.d/(command basename $pkg)\_$target
case \*
set target $fisher_path/functions/$target
end
end
echo "linking $target" | command sed "s|$HOME|~|" >&2
if set -q opts[1]
command ln -sf $src $target
else
command cp -f $src $target
end
switch $target
case \*.fish
source $target >/dev/null 2>/dev/null
end
end
end
function _fisher_rm -a pkg
for src in $pkg/{conf.d,completions,functions}/**.* $pkg/*.fish
set -l target (command basename $src)
set -l filename (command basename $target .fish)
switch $src
case $pkg/conf.d\*
test "$filename.fish" = "$target"; and emit "$filename"_uninstall
set target conf.d/$target
case $pkg/completions\*
test "$filename.fish" = "$target"; and complete -ec $filename
set target completions/$target
case $pkg/{,functions}\*
test "$filename.fish" = "$target"; and functions -e $filename
switch $target
case uninstall.fish
source $src
continue
case {init,key_bindings}.fish
set target conf.d/(command basename $pkg)\_$target
case \*
set target functions/$target
end
end
command rm -f $fisher_path/$target
end
if not functions -q fish_prompt
source "$__fish_datadir$__fish_data_dir/functions/fish_prompt.fish"
end
end
function _fisher_jobs
jobs $argv | command awk '/^[0-9]+\t/ { print $1 }'
end
function _fisher_now -a elapsed
switch (command uname)
case Darwin \*BSD
command perl -MTime::HiRes -e 'printf("%.0f\n", (Time::HiRes::time() * 1000) - $ARGV[0])' $elapsed
case \*
math (command date "+%s%3N") - "0$elapsed"
end
end

View File

@@ -0,0 +1 @@
/home/marc/.fzf/shell/key-bindings.fish

260
.config/i3/config Normal file
View File

@@ -0,0 +1,260 @@
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see https://i3wm.org/docs/userguide.html for a complete reference!
set $mod Mod4
# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
# font pango:monospace 8
# This font is widely installed, provides lots of unicode glyphs, right-to-left
# text rendering and scalability on retina/hidpi displays (thanks to pango).
font pango:DejaVu Sans Mono 8
# Before i3 v4.8, we used to recommend this one as the default:
# font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
# The font above is very space-efficient, that is, it looks good, sharp and
# clear in small sizes. However, its unicode glyph coverage is limited, the old
# X core fonts rendering does not support right-to-left and this being a bitmap
# font, it doesnt scale on retina/hidpi displays.
# Configure border style <normal|1pixel|pixel xx|none|pixel>
new_window pixel 1
new_float normal
# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod
# start a terminal
set $terminal termite
bindsym $mod+Return exec $terminal
bindsym $mod+Shift+Return split v;exec $terminal
# kill focused window
bindsym $mod+q kill
# start rofi (a program launcher)
bindsym $mod+space exec --no-startup-id rofi -show run
focus_follows_mouse no
# change focus
bindsym $mod+h focus left
bindsym $mod+j focus down
bindsym $mod+k focus up
bindsym $mod+l focus right
# alternatively, you can use the cursor keys:
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right
# change focus (i3-vim compatibility)
# bindsym --release $mod+h exec --no-startup-id "i3-vim-nav h"
# bindsym --release $mod+j exec --no-startup-id "i3-vim-nav j"
# bindsym --release $mod+k exec --no-startup-id "i3-vim-nav k"
# bindsym --release $mod+l exec --no-startup-id "i3-vim-nav l"
# bindsym --release $mod+Left exec --no-startup-id "i3-vim-nav h"
# bindsym --release $mod+Down exec --no-startup-id "i3-vim-nav j"
# bindsym --release $mod+Up exec --no-startup-id "i3-vim-nav k"
# bindsym --release $mod+Right exec --no-startup-id "i3-vim-nav l"
# move focused window
bindsym $mod+Shift+h move left
bindsym $mod+Shift+j move down
bindsym $mod+Shift+k move up
bindsym $mod+Shift+l move right
# alternatively, you can use the cursor keys:
bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right
# split orientation
bindsym $mod+z split h;exec notify-send 'tile horizontally'
bindsym $mod+v split v;exec notify-send 'tile vertically'
# bindsym $mod+q split toggle
# enter fullscreen mode for the focused container
bindsym $mod+f fullscreen toggle
# change container layout (stacked, tabbed, toggle split)
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split
# toggle tiling / floating
bindsym $mod+Shift+space floating toggle
# change focus between tiling / floating windows
# bindsym $mod+space focus mode_toggle
# focus the parent container
bindsym $mod+a focus parent
# focus the child container
#bindsym $mod+d focus child
###################################################################################################
#################### WORKSPACES ########################
###################################################################################################
# set workspace variables
set $ws1 1
set $ws2 2
set $ws3 3
set $ws4 4
set $ws5 5
set $ws6 6
set $ws7 7
set $ws8 8
set $ws9 9
set $ws10 10
# switch to workspace
bindsym $mod+1 workspace $ws1
bindsym $mod+2 workspace $ws2
bindsym $mod+3 workspace $ws3
bindsym $mod+4 workspace $ws4
bindsym $mod+5 workspace $ws5
bindsym $mod+6 workspace $ws6
bindsym $mod+7 workspace $ws7
bindsym $mod+8 workspace $ws8
bindsym $mod+9 workspace $ws9
bindsym $mod+0 workspace $ws10
# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace $ws1; workspace $ws1
bindsym $mod+Shift+2 move container to workspace $ws2; workspace $ws2
bindsym $mod+Shift+3 move container to workspace $ws3; workspace $ws3
bindsym $mod+Shift+4 move container to workspace $ws4; workspace $ws4
bindsym $mod+Shift+5 move container to workspace $ws5; workspace $ws5
bindsym $mod+Shift+6 move container to workspace $ws6; workspace $ws6
bindsym $mod+Shift+7 move container to workspace $ws7; workspace $ws7
bindsym $mod+Shift+8 move container to workspace $ws8; workspace $ws8
bindsym $mod+Shift+9 move container to workspace $ws9; workspace $ws9
bindsym $mod+Shift+0 move container to workspace $ws10; workspace $ws10
# move workspaces
bindsym $mod+Control+h move workspace to output left
bindsym $mod+Control+Left move workspace to output left
bindsym $mod+Control+l move workspace to output right
bindsym $mod+Control+Right move workspace to output right
###################################################################################################
#################### WALLPAPER ########################
###################################################################################################
exec_always --no-startup-id ~/.config/i3/scripts/wallpapers.sh
exec_always --no-startup-id compton
###################################################################################################
#################### PROGRAMS ########################
###################################################################################################
# Launch programs
bindsym $mod+Control+1 exec slack
bindsym $mod+Control+3 exec firefox
bindsym $mod+Control+0 exec spotify
# Assign workspaces
assign [class="Slack"] $ws1
assign [class="Firefox"] $ws3
for_window [class="Spotify"] move to workspace $ws10
# reload the configuration file
bindsym $mod+Shift+c reload
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Shift+r restart
set $Locker i3lock -c 112233 && sleep 1
set $mode_system System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown
mode "$mode_system" {
bindsym l exec --no-startup-id $Locker, mode "default"
bindsym e exec --no-startup-id i3-msg exit, mode "default"
bindsym s exec --no-startup-id $Locker && systemctl suspend, mode "default"
bindsym h exec --no-startup-id $Locker && systemctl hibernate, mode "default"
bindsym r exec --no-startup-id systemctl reboot, mode "default"
bindsym Shift+s exec --no-startup-id systemctl poweroff -i, mode "default"
# back to normal: Enter or Escape
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym $mod+End mode "$mode_system"
# resize window (you can also use the mouse for that)
mode "resize" {
# These bindings trigger as soon as you enter the resize mode
# Pressing left will shrink the windows width.
# Pressing right will grow the windows width.
# Pressing up will shrink the windows height.
# Pressing down will grow the windows height.
bindsym h resize shrink width 10 px or 10 ppt
bindsym j resize grow height 10 px or 10 ppt
bindsym k resize shrink height 10 px or 10 ppt
bindsym l resize grow width 10 px or 10 ppt
# same bindings, but for the arrow keys
bindsym Left resize shrink width 10 px or 10 ppt
bindsym Down resize grow height 10 px or 10 ppt
bindsym Up resize shrink height 10 px or 10 ppt
bindsym Right resize grow width 10 px or 10 ppt
# back to normal: Enter or Escape
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym $mod+r mode "resize"
# Autostart applications
exec_always --no-startup-id $HOME/.config/polybar/launch.sh
exec --no-startup-id ibus-daemon -d -r
# Pulse Audio controls
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +5% #increase sound volume
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -5% #decrease sound volume
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle # mute sound
# Sreen brightness controls
bindsym XF86MonBrightnessUp exec "$HOME/.config/i3/scripts/brightness.sh + eDP-1"
bindsym XF86MonBrightnessDown exec "$HOME/.config/i3/scripts/brightness.sh - eDP-1"
# Touchpad controls
# bindsym XF86TouchpadToggle exec /some/path/toggletouchpad.sh # toggle touchpad
# Tap touchpad to click
# exec xinput set-prop 12 276 1
# Toggle displays
bindsym $mod+p exec --no-startup-id ~/.config/i3/scripts/swap_monitors.sh
# Media player controls
bindsym XF86AudioPlay exec playerctl play-pause
bindsym XF86AudioPause exec playerctl play-pause
bindsym XF86AudioNext exec playerctl next
bindsym XF86AudioPrev exec playerctl previous
# Keyboard layout
bindsym $mod+Shift+i exec ~/.config/polybar/scripts/ibus_select.py
bindsym $mod+Shift+Home exec setxkbmap -layout es -variant cat & ibus engine xkb:es:cat:cat
# Wifi
bindsym $mod+Shift+w exec ~/.config/polybar/scripts/wifi_connect.py
# Order of screens
exec --no-startup-id xrandr --output DP-2 --right-of eDP-1
exec --no-startup-id xrandr --output DP-1 --right-of DP-2

View File

@@ -0,0 +1,9 @@
#!/bin/sh
CURRBRIGHT=$(xrandr --current --verbose | grep -m 1 'Brightness:' | cut -f2- -d:)
if [ "$1" = "+" ] && [ $(echo "$CURRBRIGHT < 1" | bc) -eq 1 ]
then
xrandr --output $2 --brightness $(echo "$CURRBRIGHT + 0.1" | bc)
elif [ "$1" = "-" ] && [ $(echo "$CURRBRIGHT > 0" | bc) -eq 1 ]
then
xrandr --output $2 --brightness $(echo "$CURRBRIGHT - 0.1" | bc)
fi

View File

@@ -0,0 +1,49 @@
#!/bin/bash
INTERNAL_OUTPUT="eDP-1"
EXTERNAL_OUTPUT_1="DP-1"
EXTERNAL_OUTPUT_2="DP-2"
## MONITOR CONFIGURATION
# .----------. .------------. .------------.
# | | | | | |
# | eDP-1 | | DP-2 | | DP-1 |
# | | | | | |
# '----------' '------------' '------------'
# /_/_/__\_\_\ I I
# /_/_/____\_\_\ _I_ _I_
# if we don't have a file, start at zero
if [ ! -f "/tmp/monitor_mode.dat" ] ; then
monitor_mode="all"
# otherwise read the value from the file
else
monitor_mode=`cat /tmp/monitor_mode.dat`
fi
if [ $monitor_mode = "all" ]; then
monitor_mode="INTERNAL"
xrandr --output $INTERNAL_OUTPUT --auto
xrandr --output $EXTERNAL_OUTPUT_1 --off
xrandr --output $EXTERNAL_OUTPUT_2 --off
notify-send 'External display OFF'
# elif [ $monitor_mode = "EXTERNAL" ]; then
# monitor_mode="INTERNAL"
# xrandr --output $INTERNAL_OUTPUT --auto
# xrandr --output $EXTERNAL_OUTPUT_1 --off
# xrandr --output $EXTERNAL_OUTPUT_2 --off
# elif [ $monitor_mode = "INTERNAL" ]; then
# monitor_mode="CLONES"
# xrandr --output $INTERNAL_OUTPUT --auto --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT
else
monitor_mode="all"
xrandr --output $INTERNAL_OUTPUT --auto
xrandr --output $EXTERNAL_OUTPUT_1 --auto --right-of $INTERNAL_OUTPUT
xrandr --output $EXTERNAL_OUTPUT_2 --auto --right-of $EXTERNAL_OUTPUT_1
~/.config/polybar/launch.sh
notify-send 'External display ON'
fi
echo "${monitor_mode}" > /tmp/monitor_mode.dat

View File

@@ -0,0 +1,18 @@
#!/bin/bash
script_name=${BASH_SOURCE[0]}
for pid in $(pidof -x $script_name); do
if [ $pid != $$ ]; then
kill -9 $pid
fi
done
# source /home/marc/venv/marc/bin/activate
while true
do
# python /home/marc/Pictures/Pixel/render.py
# feh --bg-center /home/marc/Pictures/Pixel/rendered.bmp
feh --randomize --bg-fill ~/Pictures/Island/extra/*.jpg
sleep 5m
done

377
.config/nvim/init.vim Normal file
View File

@@ -0,0 +1,377 @@
" set the runtime path to include Vundle and initialize
set rtp+=~/.config/nvim/bundle/Vundle.vim
call vundle#begin('~/.config/nvim/bundle')
" install with :PluginInstall
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
"-------------------=== Code/Project navigation ===-------------
Plugin 'scrooloose/nerdtree' " Project and file navigation
Plugin 'Xuyuanp/nerdtree-git-plugin' " NerdTree git functionality
Plugin 'airblade/vim-gitgutter' " Show git changes in gutter
Plugin 'majutsushi/tagbar' " Class/module browser
Plugin 'vim-airline/vim-airline' " Lean & mean status/tabline for vim
Plugin 'vim-airline/vim-airline-themes' " Themes for airline
Plugin 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } " requires fzf and the_silver_searcher (ag)
Plugin 'junegunn/fzf.vim'
Plugin 'tpope/vim-commentary' " Comment lines
Plugin 'tpope/vim-fugitive'
"-------------------=== Other ===-------------------------------
Plugin 'jiangmiao/auto-pairs'
Plugin 'flazz/vim-colorschemes' " Colorschemes
Plugin 'chrisbra/Colorizer' " Colorize colornames and codes
Plugin 'guns/xterm-color-table.vim' " Display a color table
Plugin 'dylanaraps/wal.vim'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-sensible'
Plugin 'ntpeters/vim-better-whitespace'
"---------------=== Code completion ===---------------------------
Plugin 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
"-------------------=== Language Support ===--------------------
" Plugin 'scrooloose/syntastic'
Plugin 'w0rp/ale'
"---------------------=== Fish ===-----------------------------
Plugin 'dag/vim-fish'
"-------------------=== Python ===-----------------------------
Plugin 'jmcantrell/vim-virtualenv', { 'for': 'python' }
Plugin 'numirias/semshi', {'do': ':UpdateRemotePlugins'}
Plugin 'davidhalter/jedi-vim', { 'for': 'python' }
Plugin 'zchee/deoplete-jedi', { 'for': 'python' }
Plugin 'fisadev/vim-isort'
" Plugin 'vim-vdebug/vdebug'
"-------------------=== Cypher ===-----------------------------
Plugin 'neo4j-contrib/cypher-vim-syntax', { 'for': 'cypher' }
"-------------------=== JSON ===-------------------------------
Plugin 'elzr/vim-json'
"------------------=== Markdown ===----------------------------
Plugin 'tpope/vim-markdown'
Plugin 'vim-scripts/SyntaxRange'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype on
filetype plugin on
"=====================================================
"" General settings
"=====================================================
set nocompatible " required
filetype off " required
set hidden
set showtabline=0
let mapleader=" "
set encoding=utf-8
colorscheme zenburn
" set background=dark
set t_Co=256 " 256 colors
set shell=/bin/bash
set number " show line numbers
set ruler
set ttyfast " terminal acceleration
set tabstop=4 " 4 whitespaces for tabs visual presentation
set shiftwidth=4 " shift lines by 4 spaces
set expandtab " expand tabs into spaces
set colorcolumn=121
set showmatch " shows matching part of bracket pairs (), [], {}
set nobackup " no backup files
set nowritebackup " only in case you don't want a backup file while editing
set noswapfile " no swap files
set scrolloff=20 " let 10 lines before/after cursor during scroll
set clipboard=unnamedplus " use system clipboard
set exrc " enable usage of additional .vimrc files from working directory
set secure " prohibit .vimrc files to execute shell, create files, etc...
set nocursorline " shows line under the cursor's line
set lazyredraw " do not redraw screen in the middle of a macro
set smartcase
set ignorecase
set undofile
set inccommand=nosplit
"=====================================================
"" Deactivate arrows
"=====================================================
noremap <Up> <Nop>
noremap <Down> <Nop>
noremap <Left> <Nop>
noremap <Right> <Nop>
inoremap <Left> <Nop>
inoremap <Right> <Nop>
"=====================================================
"" Tabs / Buffers settings
"=====================================================
tab sball
set switchbuf=useopen
set laststatus=2
nmap <leader>o <C-o>
nmap <leader>i <C-i>
nmap <leader>b :bprev<CR>
nmap <leader>f :bnext<CR>
nmap <silent> <leader>q :bp <BAR> bd #<CR>
nnoremap <silent> <C-w><C-h> :vertical resize -5<cr>
nnoremap <silent> <C-w><C-j> :resize +5<cr>
nnoremap <silent> <C-w><C-k> :resize -5<cr>
nnoremap <silent> <C-w><C-l> :vertical resize +5<cr>
"=====================================================
"" Relative Numbering
"=====================================================
nnoremap <F4> :set relativenumber!<CR>
"=====================================================
"" Search settings
"=====================================================
set hlsearch " highlight search results
" clear search highlight
nnoremap <silent> <leader>h :nohlsearch<CR>
" replace word under cursor
" nnoremap <leader>r :%s/\<<C-r><C-w>\>/
"=====================================================
"" Ale
"=====================================================
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
let g:ale_sign_column_always = 1
let g:ale_set_highlights = 0
let b:ale_warn_about_trailing_whitespace = 1
let g:ale_emit_conflict_warnings = 1
let g:ale_completion_enabled = 0
let g:syntastic_python_pylint_post_args="--max-line-length=120"
let g:ale_linters = {
\ 'python': ['flake8', 'pep8'],
\}
let g:ale_fixers = {
\ '*': ['remove_trailing_lines'],
\ 'python': ['isort', 'autopep8'],
\}
let g:ale_fix_on_save = 0
let g:ale_list_window_size = 15
let g:ale_echo_cursor = 1 " workaround for vim bug
nmap <silent> <leader>ef :ALEFix<cr>
nmap <silent> <leader>ej :ALENext<cr>
nmap <silent> <leader>ek :ALEPrevious<cr>
au FileType python setlocal formatprg=autopep8\ --max-line-length=120\ - " mapped to gq by default
"=====================================================
"" AirLine settings
"=====================================================
let g:airline#extensions#tabline#enabled=1
let g:airline#extensions#tabline#formatter='unique_tail_improved'
let g:airline_theme='zenburn' " set airline theme
let g:airline_powerline_fonts = 1
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
" let g:airline_left_sep = ''
" let g:airline_right_sep = ''
" let g:airline_symbols.notexists = ''
"=====================================================
"" TagBar settings
"=====================================================
let g:tagbar_autofocus=1
let g:tagbar_width=42
map <C-t> :TagbarToggle<CR>
" autocmd BufWinEnter *.py :call tagbar#autoopen(0)
autocmd BufWinLeave *.py :TagbarClose
"=====================================================
"" NERDTree settings
"=====================================================
let NERDTreeIgnore = ['\.pyc$', '\.pyo$', '__pycache__$', '\~$'] " Ignore files in NERDTree
let NERDTreeWinSize = 40
autocmd VimEnter * if !argc() | NERDTree | endif " Load NERDTree only if vim is run without arguments
map <C-n> :NERDTreeToggle<CR>
nmap <leader>n :NERDTreeFind<CR>
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'
let NERDTreeShowHidden = 1
let NERDTreeMinimalUI = 1
"=====================================================
"" GitGutter
"=====================================================
nmap ]h <Plug>GitGutterNextHunk
nmap [h <Plug>GitGutterPrevHunk
let g:updatetime = 250
"=====================================================
"" Indent Guides Settings
"=====================================================
set listchars=tab:\ ,trail:•,extends:#,nbsp:.
"=====================================================
"" Window Navigation
"=====================================================
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
"=====================================================
"" Deoplete
"=====================================================
let g:deoplete#enable_at_startup = 1
let g:python_host_prog = '/usr/bin/python'
let g:python3_host_prog = '/usr/bin/python3'
let g:deoplete#auto_complete_delay = 0
"=====================================================
"" Vim Virtualenv
"=====================================================
let g:virtualenv_auto_activate = 1
"=====================================================
"" FZF
"=====================================================
"
nnoremap <C-f>f :Files<cr>
nnoremap <C-f>t :Ag<cr>
" Search current word
nnoremap <C-f>w :Ag <C-R><C-W><cr>
let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git -g ""' " search in all hidden files but .git
let g:fzf_colors =
\ { 'fg': ['fg', 'Normal'],
\ 'bg': ['bg', 'Normal'],
\ 'hl': ['fg', 'Comment'],
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'],
\ 'border': ['fg', 'Ignore'],
\ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] }
"=====================================================
"" Auto Pairs
"=====================================================
let g:AutoPairsFlyMode = 0
let g:AutoPairsShortcutFastWrap = '<C-s>'
""=====================================================
""" WhiteSpace Highlight
""=====================================================
let g:strip_whitespace_on_save=1
""=====================================================
""" iSort
""=====================================================
let g:vim_isort_map = '<C-I>'
let g:vim_isort_python_version = 'python3'
""=====================================================
""" Colorizer
""=====================================================
let g:colorizer_auto_color = 1
let g:colorizer_disable_bufleave = 1
let g:colorizer_skip_comments = 1
let g:colorizer_colornames = 0
autocmd BufNewFile,BufRead,BufEnter,BufWinEnter * call timer_start(100, { tid -> execute('ColorHighlight')})
""=====================================================
""" Semshi
""=====================================================
function MyCustomHighlights()
hi semshiLocal ctermfg=209 guifg=#ff875f
hi semshiGlobal ctermfg=214 guifg=#ffaf00
hi semshiImported ctermfg=214 guifg=#ffaf00 cterm=bold gui=bold
hi semshiParameter ctermfg=75 guifg=#5fafff
hi semshiParameterUnused ctermfg=117 guifg=#87d7ff cterm=underline gui=underline
hi semshiFree ctermfg=218 guifg=#ffafd7
hi semshiBuiltin ctermfg=207 guifg=#ff5fff
hi semshiAttribute ctermfg=49 guifg=#00ffaf
hi semshiSelf ctermfg=249 guifg=#b2b2b2
hi semshiUnresolved ctermfg=226 guifg=#ffff00 cterm=underline gui=underline
hi semshiSelected ctermfg=231 guifg=#ffffff ctermbg=161 guibg=#d7005f
hi semshiErrorSign ctermfg=231 guifg=#ffffff ctermbg=160 guibg=#d70000
hi semshiErrorChar ctermfg=231 guifg=#ffffff ctermbg=160 guibg=#d70000
sign define semshiError text=E> texthl=semshiErrorSign
endfunction
autocmd FileType python call MyCustomHighlights()
autocmd ColorScheme * call MyCustomHighlights()
"=====================================================
"" Jedi Vim
"=====================================================
let g:jedi#auto_initialization = 1 " disable jedi
let g:jedi#auto_vim_configuration = 1 " disable jedi
let g:jedi#completions_enabled = 0 " disable completions
let g:jedi#goto_definitions_command = ""
let g:jedi#documentation_command = "K"
let g:jedi#goto_command = "<leader>d"
let g:jedi#goto_assignments_command = "<leader>g"
let g:jedi#usages_command = "<leader>u"
let g:jedi#completions_command = "<C-Space>"
let g:jedi#rename_command = "<leader>r"
let g:jedi#show_call_signatures = "2"
let g:jedi#popup_on_dot = 0
let g:jedi#smart_auto_mappings = 0
let g:jedi#use_tabs_not_buffers = 0
autocmd BufWinEnter '__doc__' setlocal bufhidden=delete " delete jedi docs
" Set the background transparent
hi Normal guibg=NONE ctermbg=NONE
"=====================================================
"" Others
"=====================================================
" Pretty format XML
com! FormatXML :%!python3 -c "import xml.dom.minidom, sys; print(xml.dom.minidom.parse(sys.stdin).toprettyxml())"
nnoremap = :FormatXML<Cr>

333
.config/polybar/config Normal file
View File

@@ -0,0 +1,333 @@
;==========================================================
;
;
; ██████╗ ██████╗ ██╗ ██╗ ██╗██████╗ █████╗ ██████╗
; ██╔══██╗██╔═══██╗██║ ╚██╗ ██╔╝██╔══██╗██╔══██╗██╔══██╗
; ██████╔╝██║ ██║██║ ╚████╔╝ ██████╔╝███████║██████╔╝
; ██╔═══╝ ██║ ██║██║ ╚██╔╝ ██╔══██╗██╔══██║██╔══██╗
; ██║ ╚██████╔╝███████╗██║ ██████╔╝██║ ██║██║ ██║
; ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝
;
;
; To learn more about how to configure Polybar
; go to https://github.com/polybar/polybar
;
; The README contains a lot of information
;
;==========================================================
[colors]
background = #222
background-alt = #444
foreground = #dfdfdf
foreground-alt = #555
primary = #ffb52a
secondary = #e60053
alert = #bd2c40
################################################################################
################################################################################
############ MAINBAR-I3 ############
################################################################################
################################################################################
[bar/mainbar-i3]
;https://github.com/jaagr/polybar/wiki/Configuration
monitor = ${env:MONITOR}
;monitor-fallback = HDMI1
monitor-strict = false
bottom = false
fixed-center = true
width = 100%
height = 20
;offset-x = 1%
;offset-y = 1%
background = ${colors.background}
foreground = ${colors.foreground}
; Background gradient (vertical steps)
; background-[0-9]+ = #aarrggbb
radius = 0.0
line-size = 2
line-color = #000000
;border-size = 0
;border-left-size = 25
;border-right-size = 25
;border-top-size = 10
;border-bottom-size = 25
border-color = #000000
padding-left = 1
padding-right = 1
module-margin-left = 0
module-margin-right = 0
;https://github.com/jaagr/polybar/wiki/Fonts
font-0 = "UbuntuMono Nerd Font Mono:style=Regular:size=10;2"
font-1 = "UbuntuMono Nerd Font:size=16;3"
font-2 = "Font Awesome 5 Free:style=Regular:pixelsize=8;1"
font-3 = "Font Awesome 5 Free:style=Solid:pixelsize=8;1"
font-4 = "Font Awesome 5 Brands:pixelsize=8;1"
modules-left = i3 spotify1
modules-center = date
modules-right = xkeyboard wifi pulseaudio battery
separator = " : "
tray-position = left
tray-detached = false
tray-maxsize = 20
tray-background = ${colors.background}
tray-offset-x = 0
tray-offset-y = 0
tray-padding = 4
tray-scale = 1.0
; Enable support for inter-process messaging
; See the Messaging wiki page for more details.
enable-ipc = true
; Fallback click handlers that will be called if
; there's no matching module handler found.
click-left =
click-middle =
click-right =
scroll-up = i3wm-wsnext
scroll-down = i3wm-wsprev
double-click-left =
double-click-middle =
double-click-right =
; Requires polybar to be built with xcursor support (xcb-util-cursor)
; Possible values are:
; - default : The default pointer as before, can also be an empty string (default)
; - pointer : Typically in the form of a hand
; - ns-resize : Up and down arrows, can be used to indicate scrolling
cursor-click =
cursor-scroll =
[module/xwindow]
type = internal/xwindow
label = %title:0:30:...%
[module/xkeyboard]
type = internal/xkeyboard
blacklist-0 = num lock
format = <label-indicator> <label-layout>
format-foreground = ${colors.foreground-alt}
format-prefix =
format-prefix-foreground = ${colors.background}
format-prefix-underline = ${colors.secondary}
label-layout = %layout%
;label-layout-underline = ${colors.secondary}
label-indicator-padding = 2
label-indicator-margin = 1
label-indicator-background = ${colors.secondary}
label-indicator-underline = ${colors.secondary}
[module/filesystem]
type = internal/fs
interval = 25
mount-0 = /
label-mounted = %{F#0a81f5}%mountpoint%%{F-}: %percentage_used%%
label-unmounted = %mountpoint% not mounted
label-unmounted-foreground = ${colors.foreground-alt}
[module/bspwm]
type = internal/bspwm
label-focused = %index%
label-focused-background = ${colors.background-alt}
label-focused-underline= ${colors.primary}
label-focused-padding = 2
label-occupied = %index%
label-occupied-padding = 2
label-urgent = %index%!
label-urgent-background = ${colors.alert}
label-urgent-padding = 2
label-empty = %index%
label-empty-foreground = ${colors.foreground-alt}
label-empty-padding = 2
; Separator in between workspaces
; label-separator = |
[module/i3]
type = internal/i3
format = <label-state> <label-mode>
index-sort = true
wrapping-scroll = false
; Only show workspaces on the same output as the bar
;pin-workspaces = true
label-mode-padding = 2
label-mode-foreground = #000
label-mode-background = ${colors.primary}
; focused = Active workspace on focused monitor
label-focused = %index%
label-focused-background = ${colors.background-alt}
label-focused-underline= ${colors.secondary}
label-focused-padding = 2
; unfocused = Inactive workspace on any monitor
label-unfocused = %index%
label-unfocused-padding = 2
; visible = Active workspace on unfocused monitor
label-visible = %index%
label-visible-background = ${self.label-focused-background}
label-visible-underline = ${colors.primary}
label-visible-padding = ${self.label-focused-padding}
; urgent = Workspace with urgency hint set
label-urgent = %index%
label-urgent-background = ${colors.alert}
label-urgent-padding = 2
[module/xbacklight]
type = internal/xbacklight
format = <label> <bar>
label = BL
bar-width = 10
bar-indicator = |
bar-indicator-foreground = #fff
bar-indicator-font = 2
bar-fill = ─
bar-fill-font = 2
bar-fill-foreground = #9f78e1
bar-empty = ─
bar-empty-font = 2
bar-empty-foreground = ${colors.foreground-alt}
[module/date]
type = internal/date
interval = 1
date = %A, %d %B %Y
time = %H:%M:%S
time-alt = %H:%M:%S %Z (%z)
date-alt = %Y-%m-%d
format-prefix =
format-prefix-foreground = ${colors.foreground-alt}
format-underline =
label = %date% · %time%
[module/pulseaudio]
type = internal/pulseaudio
format-volume = <label-volume> <bar-volume>
label-volume = VOL %percentage%%
label-volume-foreground = ${colors.foreground-alt}
label-muted = muted
label-muted-foreground = #666
bar-volume-width = 10
bar-volume-foreground-0 = #55aa55
bar-volume-foreground-1 = #55aa55
bar-volume-foreground-2 = #55aa55
bar-volume-foreground-3 = #55aa55
bar-volume-foreground-4 = #55aa55
bar-volume-foreground-5 = #f5a70a
bar-volume-foreground-6 = #ff5555
bar-volume-gradient = false
bar-volume-indicator = |
bar-volume-indicator-font = 0
bar-volume-fill = -
bar-volume-fill-font = 0
bar-volume-empty = -
bar-volume-empty-font = 0
bar-volume-empty-foreground = ${colors.foreground-alt}
[module/battery]
type = internal/battery
battery = BAT0
adapter = AC
full-at = 98
format-charging-prefix = "▴"
format-charging = <label-charging>
format-charging-foreground = #55aa55
;format-charging = <animation-charging> <label-charging>
format-charging-underline =
;format-discharging = <animation-discharging> <label-discharging>
format-discharging-prefix = "▾"
format-discharging = <label-discharging>
format-discharging-foreground = #f5a70a
format-discharging-underline =
format-full = FULL BATTERY
;format-full-prefix = "▪"
format-full-foreground = #55aa55
format-full-underline = ${self.format-charging-underline}
ramp-capacity-0 = 
ramp-capacity-1 = 
ramp-capacity-2 = 
ramp-capacity-foreground = ${colors.foreground-alt}
[module/spotify1]
type = custom/script
interval = 1
exec = ~/.config/polybar/scripts/spotify.sh
;format = <label>
format-foreground = ${colors.foreground-alt}
format-background = ${colors.background}
format-padding = 2
format-underline =
format-prefix = " "
format-prefix-foreground = ${colors.foreground-alt}
label = %output:0:70%
[module/wifi]
type = custom/script
;tail = false
interval = 5
exec = ~/.config/polybar/scripts/wifi_status.py
;double-click-right = nmcli device wifi rescan
double-click-left = ~/.config/polybar/scripts/wifi_connect.py
;format = <label>
format-foreground = ${colors.foreground-alt}
format-background = ${colors.background}
format-padding = 0
format-underline =
format-prefix-foreground = ${colors.foreground-alt}
label = %output:0:40%
[settings]
screenchange-reload = true
;compositing-background = xor
;compositing-background = screen
;compositing-foreground = source
;compositing-border = over
;pseudo-transparency = false
[global/wm]
margin-top = 5
margin-bottom = 5

14
.config/polybar/launch.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
# Terminate already running bar instances
killall -q polybar
# Wait until the processes have been shut down
while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done
for m in $(polybar --list-monitors | cut -d":" -f1); do
WIRELESS=$(ls /sys/class/net/ | grep ^wl | awk 'NR==1{print $1}') MONITOR=$m polybar --reload mainbar-i3 &
done
echo "Bars launched..."

View File

@@ -0,0 +1,42 @@
#!/usr/bin/python3
import subprocess
from collections import namedtuple
IbusEngine = namedtuple('IbusEngine', ('code', 'name'))
# ---------- BEGINNING OF SCRIPT ----------
# Get available engines
list_engines_command = ['ibus', 'list-engine']
list_engines_result = subprocess.run(list_engines_command, stdout=subprocess.PIPE)
list_engines_output = list_engines_result.stdout.decode('utf-8')
engines = [IbusEngine(*[l.strip() for l in line.split(' - ')])
for line in list_engines_output.split('\n') if line and not line.startswith('language:')]
# Use rofi to ask the user which ibus engine to use
ROFI_IBUS_PROMPT = "layout: "
rofi_command = ['rofi', '-dmenu', '-i', '-format', 'i', '-p', ROFI_IBUS_PROMPT]
input_str = '\n'.join([engine.name for engine in engines])
rofi_result = subprocess.run(rofi_command, input=input_str, stdout=subprocess.PIPE, encoding='utf-8')
if rofi_result.returncode != 0:
exit(rofi_result.returncode)
rofi_output = rofi_result.stdout.split(":")
index = int(rofi_output[0])
if index < 0:
exit(-1)
change_layout_command = ['ibus', 'engine', engines[index].code]
change_layout_result = subprocess.run(change_layout_command)
if change_layout_result.returncode != 0:
subprocess.run(['notify-send', '"{}"'.format(change_layout_result.stdout)])
exit(change_layout_result.returncode)

View File

@@ -0,0 +1,41 @@
#!/bin/bash
main() {
if ! pgrep -x spotify >/dev/null; then
echo ""
exit
fi
cmd="org.freedesktop.DBus.Properties.Get"
domain="org.mpris.MediaPlayer2"
path="/org/mpris/MediaPlayer2"
meta=$(dbus-send --print-reply --dest=${domain}.spotify \
/org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:${domain}.Player string:Metadata)
ttype=$(echo "$meta" | sed -nr '/mpris:trackid"/,+2s/^ +variant +string "[^:]*:(.*):.*"$/\1/p')
if [ "$ttype" = "ad" ]; then
if [ $(pactl list sinks | sed -n 's/.*Mute:\s*//p' | tail -n 1) = "no" ]; then
echo "TRUE" > /tmp/spotify_mute
pactl set-sink-mute @DEFAULT_SINK@ 1
echo "MUTING AN AD ;)"
fi
else
if [ -f "/tmp/spotify_mute" ] ; then
if [ $(cat /tmp/spotify_mute) = "TRUE" ]; then
echo "FALSE" > /tmp/spotify_mute
pactl set-sink-mute @DEFAULT_SINK@ 0
fi
fi
# Normal track
artist=$(echo "$meta" | sed -nr '/xesam:artist"/,+2s/^ +string "(.*)"$/\1/p' | tail -1 | sed 's/\&/\\&/g' | sed 's#\/#\\/#g')
album=$(echo "$meta" | sed -nr '/xesam:album"/,+2s/^ +variant +string "(.*)"$/\1/p' | tail -1| sed 's/\&/\\&/g'| sed 's#\/#\\/#g')
title=$(echo "$meta" | sed -nr '/xesam:title"/,+2s/^ +variant +string "(.*)"$/\1/p' | tail -1 | sed 's/\&/\\&/g'| sed 's#\/#\\/#g')
echo "${*:-%artist% - %title%}" | sed "s/%artist%/$artist/g;s/%title%/$title/g;s/%album%/$album/g"i | sed "s/\&/\&/g" | sed "s#\/#\/#g"
fi
}
main "$@"

View File

@@ -0,0 +1,114 @@
#!/usr/bin/python3
import subprocess
from collections import namedtuple
APListItem = namedtuple('APListItem', ('active', 'ssid', 'mode', 'channel', 'rate', 'signal', 'bars', 'security'))
ConListItem = namedtuple('ConListItem', ('name', 'uuid', 'type', 'device'))
# ---------- ACTIONS ----------
Action = namedtuple('Action', ('action', 'item'))
# Action types
ACT_CONNECT_WLAN = 'connect_wlan'
ACT_DISCONNECT_WLAN = 'disconnect_wlan'
ACT_CONNECT_VPN = 'connect_vpn'
ACT_DISCONNECT_VPN = 'disconnect_vpn'
WLAN_ITEM_FORMAT = '{bars} ({signal:>3}%) -- {ssid} ({rate})'
VPN_ITEM_FORMAT = 'VPN -- {name}'
def format_action(action):
item = action.item
if action.action == ACT_CONNECT_VPN:
return '[con] ' + VPN_ITEM_FORMAT.format(name=item.name)
if action.action == ACT_CONNECT_WLAN:
return '[con] ' + WLAN_ITEM_FORMAT.format(bars=item.bars, signal=item.signal, ssid=item.ssid, rate=item.rate)
if action.action == ACT_DISCONNECT_VPN:
return '[dis] ' + VPN_ITEM_FORMAT.format(name=item.name)
if action.action == ACT_DISCONNECT_WLAN:
return '[dis] ' + WLAN_ITEM_FORMAT.format(bars=item.bars, signal=item.signal, ssid=item.ssid, rate=item.rate)
def get_command(action):
item = action.item
if action.action == ACT_CONNECT_VPN:
return ['nmcli', 'connection', 'up', item.name], None
if action.action == ACT_CONNECT_WLAN:
return ['nmcli', 'connection', 'up', item.ssid], ['nmcli', 'device', 'wifi', 'connect', item.ssid]
if action.action == ACT_DISCONNECT_VPN:
return ['nmcli', 'connection', 'down', item.name], None
if action.action == ACT_DISCONNECT_WLAN:
return ['nmcli', 'connection', 'down', item.ssid], None
# ---------- BEGINNING OF SCRIPT ----------
# Get available wifi APs with nmcli
list_aps_command = ['nmcli', '-t', 'device', 'wifi', 'list']
list_aps_result = subprocess.run(list_aps_command, stdout=subprocess.PIPE)
list_aps_output = list_aps_result.stdout.decode('utf-8')
nm_items = [APListItem(*line.split(':')) for line in list_aps_output.split('\n') if line]
# Get VPN status
list_con_command = ['nmcli', '-t', 'connection', 'show']
list_con_result = subprocess.run(list_con_command, stdout=subprocess.PIPE)
list_con_output = list_con_result.stdout.decode('utf-8')
con_items = [ConListItem(*line.split(':')) for line in list_con_output.split('\n') if line]
available_vpns = [item for item in con_items if item.type == 'vpn' and item.device.strip() == '']
active_vpns = [item for item in con_items if item.type == 'vpn' and item.device.strip() != '']
# Make a unique list of ssids
ssids = set()
unique_wlans = []
active_wlans = []
for item in nm_items:
if item.active == '*':
active_wlans.append(item)
elif item.ssid not in ssids and item.ssid != '':
unique_wlans.append(item)
ssids.add(item.ssid)
# Build all available actions
actions = []
actions.extend(Action(ACT_DISCONNECT_WLAN, item) for item in active_wlans)
actions.extend(Action(ACT_DISCONNECT_VPN, item) for item in active_vpns)
actions.extend(Action(ACT_CONNECT_WLAN, item) for item in unique_wlans)
actions.extend(Action(ACT_CONNECT_VPN, item) for item in available_vpns)
actions_format = [format_action(action) for action in actions]
# Use rofi to ask the user which AP to connect to
ROFI_WIFI_PROMPT = "wifi: "
rofi_command = ['rofi', '-dmenu', '-i', '-format', 'i:s', '-p', ROFI_WIFI_PROMPT]
active_len = len(active_wlans) + len(active_vpns)
if active_len:
rofi_command.extend(['-a', '0-{}'.format(active_len - 1)])
input_str = '\n'.join(actions_format)
rofi_result = subprocess.run(rofi_command, input=input_str, stdout=subprocess.PIPE, encoding='utf-8')
if rofi_result.returncode != 0:
exit(rofi_result.returncode)
rofi_output = rofi_result.stdout.split(":")
index = int(rofi_output[0])
fallback_code = None
if index < 0:
exit(-1)
command, fallback_command = get_command(actions[index])
connect_result = subprocess.run(command)
if connect_result.returncode == 10:
connect_result = subprocess.run(fallback_command)
exit(connect_result.returncode)

View File

@@ -0,0 +1,39 @@
#!/usr/bin/python3
import time
import subprocess
from collections import namedtuple
APListItem = namedtuple('APListItem', ('active', 'ssid', 'mode', 'channel', 'rate', 'signal', 'bars', 'security'))
ConListItem = namedtuple('ConListItem', ('name', 'uuid', 'type', 'device'))
if True:
# Get available wifi APs with nmcli
list_aps_command = ['nmcli', '-t', 'device', 'wifi', 'list']
list_aps_result = subprocess.run(list_aps_command, stdout=subprocess.PIPE)
list_aps_output = list_aps_result.stdout.decode('utf-8')
nm_items = [APListItem(*line.split(':')) for line in list_aps_output.split('\n') if line]
active_items = [item for item in nm_items if item.active == '*']
# Get VPN status
list_con_command = ['nmcli', '-t', 'connection', 'show']
list_con_result = subprocess.run(list_con_command, stdout=subprocess.PIPE)
list_con_output = list_con_result.stdout.decode('utf-8')
con_items = [ConListItem(*line.split(':')) for line in list_con_output.split('\n') if line]
active_vpn = [item for item in con_items if item.type == 'vpn' and item.device.strip() != '']
if active_items:
active_item = active_items[0]
wifi_status = '{ssid} [{signal}%]'.format(signal=active_item.signal, ssid=active_item.ssid)
else:
wifi_status = 'disconnected'
vps_status = '[VPN]' if active_vpn else ''
print(''.join([wifi_status, vps_status]).strip())
# time.sleep(3)