diff --git a/.bash_aliases b/.bash_aliases deleted file mode 100644 index 0a13453..0000000 --- a/.bash_aliases +++ /dev/null @@ -1,555 +0,0 @@ -alias ls='ls --color=auto' -alias grep='grep --color=auto' -alias fgrep='fgrep --color=auto' -alias egrep='egrep --color=auto' -alias py='python3' -alias ipy='ipython3' -alias whatisopen='sudo netstat -pnlt' -alias calc='gcalccmd' -alias pmr='python manage.py runserver' -alias nopmr="ps auxw | grep runserver | awk '{print \$2}' | xargs kill" -alias pmm='python manage.py migrate' -alias pmmm='python manage.py makemigrations' - -# Start vim with system clipboard -alias vim="vimx" # don't alias this - make symlink instead -alias vi="vim" -alias vimdiff="vim -d" - -# git aliases -alias g='git' -alias gs='git status' -alias ga='git add' -alias gc='git commit -S' -alias gp='git push origin master' -# alias gp='for r in $(git remote); do echo "Pushing to $r" && git push $r master; done' -alias gpull='git pull --rebase origin master' -alias gl="git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all" -alias gd="git diff" -alias gds="git diff --staged" -alias gb="git branch" -alias gpp='git push production master' # push to production for personal website -# pull all remote branches -alias git-pull-branches='git branch -r | grep -v "\->" | while read remote; do git branch --track "${remote#origin/}" "$remote"; done' -# useful for daily stand-up -git-standup() { - AUTHOR=${AUTHOR:="`git config user.name`"} - - since=yesterday - if [[ $(date +%u) == 1 ]] ; then - since="2 days ago" - fi - - git log --all --since "$since" --oneline --author="$AUTHOR" -} - -# MSR registers is responsible for lag after suspend -alias checkcpu='modprobe msr; rdmsr -a 0x19a' -alias fixcpu='wrmsr -a 0x19a 0x0' - -alias muzika='xdg-open ~/Documents/Music/njoy.m3u' -alias randomstr="tr -dc a-z1-4 50' | tr 3-4 ' ' | sed 's/^ *//' | cat -s | sed 's/ / /g' |fmt" -alias battery="upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep -E 'time to empty|state|to\ full|percentage'" -alias svali_papka=download_github_folder -alias omg="sudo systemctl restart NetworkManager" -alias omg1.1="sudo rmmod iwlmvm && sudo rmmod iwlwifi; sudo modprobe iwlwifi" -alias zsh_fix="mv ~/.zsh_history ~/.zsh_history_bad; strings ~/.zsh_history_bad > ~/.zsh_history;fc -R ~/.zsh_history; rm ~/.zsh_history_bad" -alias myip="curl https://icanhazip.com" -alias rmswp="find ~/.vim/tmp/ -iname \"*swp\" -delete" -alias root="sudo su -" - - download_github_folder() { - svn checkout $(echo $1 | sed "s/\/tree\/[a-zA-Z]\+/\/trunk/") -} - - bye() { - if ps -p $(pidof rsync) 2> /dev/null - then - echo 'Rsync is running, not going to sleep.' - else - # (/bin/lock &) && sudo systemctl suspend - sudo systemctl suspend - fi -} - -alias sizeof='du -sh' -alias mkdir="mkdir -pv" - -# ls(){ -# if [[ $2 == "-l" ]]; then -# if [[ $3 != "" ]]; then -# exa -bghHliS $3 -# else -# exa -bghHliS -# fi -# else -# if [[ $2 != "" ]]; then -# /bin/ls --color=auto $2 -# else -# /bin/ls --color=auto -# fi -# fi -# } - -# Get packet manager -declare -A osInfo; -osInfo[/etc/redhat-release]=dnf -osInfo[/etc/arch-release]=pacman -osInfo[/etc/gentoo-release]=emerge -osInfo[/etc/SuSE-release]=zypp -osInfo[/etc/debian_version]=apt-get - -# for f in "${!osInfo[@]}" # bash version -for f in "${(@k)osInfo}" # zsh version -do - if [[ -f $f ]];then - pm=${osInfo[$f]} - fi -done -alias update="sudo $pm update" -alias u="update" -alias upgrade="sudo $pm upgrade" -alias install="sudo $pm install" -alias remove="sudo $pm remove" -alias reinstall="sudo $pm reinstall" - -# secureme(){ -# workon ansible; -# cd /home/viktor/ansible-play/ -# ansible-playbook -i ./hosts --extra-vars "ansible_sudo_pass=$ROOTPASS" --tags "vpn_startup" main.yml >> /dev/null -# cd /home/viktor/; -# sudo openvpn --config viktor.ovpn & -# } - - # function in(){ - # if [ $# -lt 2 ]; - # then - # echo "Usage:" - # echo "To start existing container:" - # echo "in " - # echo - # echo "To start new container:" - # echo "in new " - # return - # fi - - # if [ $# -eq 1 ] - # then - # container_name="${1/:/_}" - # else - # container_name="${2/:/_}" - # fi - - # # Check if recreating a container or reuse existing - # if [ "$1" = "new" ] - # then - # image_name=$2 - # if [[ $(docker container ls -a | grep "$container_name") ]] - # then - # if [[ $(docker ps | grep $container_name) ]] - # then - # docker stop $container_name >> /dev/null - # fi - # docker rm $container_name >> /dev/null - # fi - - # if [ -z "$3" ] - # then - # cmd="/bin/bash" - # else - # cmd="$3" - # fi - # echo "Running $cmd in $container_name" - # # docker run -it --name $container_name --publish-all=true $image_name "$cmd" && docker attach $container_name - - # xhost +local:root # allow gui apps - # docker run -it --name $container_name -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix $image_name "$cmd" - # xhost -local:root - # else - # xhost +local:root - # docker start $container_name >> /dev/null && docker attach $container_name - # xhost -local:root - # fi -# } - -# stest(){ - # snapshot_name="rootsnap" - # mount_point="$2" - - # if [ $# -ne 2 ];then - # echo "Usage:" - # echo "$0 " - # echo - # return - # fi - - # if [ ${mount_point:0:1} != '/' ]; then - # echo "Mount point must be absolute path" - # return - # fi - - # if [[ $(sudo lvs | grep $snapshot_name) ]]; then - # echo "$snapshot_name already exists!" - # # read -e -p "Do you want to discard it and create a new one?(y/N)" -i n should_discard - # echo "Do you want to discard it and create a new one?(y/N)" - # read should_discard - # should_discard=${should_discard:-"n"} - # # if [ ${(L)should_discard} = 'y' ]; then - # if [ $(echo $should_discard | awk '{print tolower($0)}') = 'y' ]; then - # sudo umount $mount_point - # sudo lvremove /dev/kubuntu-vg/$snapshot_name -y - # else - # echo "Leaving old snapshot intact" - # return - # fi - - # fi - - # sudo lvcreate -s -n $snapshot_name /dev/kubuntu-vg/root -L $1 - # sudo mount /dev/kubuntu-vg/$snapshot_name $mount_point - # sudo chroot $mount_point /bin/zsh -# } -wifi_int_name="$(cat /proc/net/wireless | perl -ne '/(\w+):/ && print $1')" - -alias ifl="ifconfig|less" -# Docker aliases -alias dsl="docker swarm leave --force" -alias dsi="docker swarm init --advertise-addr=$wifi_int_name" -alias dsjtm="docker swarm join-token manager" -alias dsjtw="docker swarm join-token worker" - -alias noip6="sudo sh -c 'echo 1 > /proc/sys/net/ipv6/conf/$wifi_int_name/disable_ipv6'" -alias yesip6="sudo sh -c 'echo 0 > /proc/sys/net/ipv6/conf/$wifi_int_name/disable_ipv6'" - -# alias omg2="killall plasmashell; plasmashell > /dev/null 2>&1 & disown" -alias omg2="kwin --replace &" -alias omg2.1="kquitapp5 plasmashell && kstart5 plasmashell" -alias aliases="vim ~/.bash_aliases && source ~/.bash_aliases" - -# alias ghcirun="ghci --make $1; ./$1" -alias lip="ifconfig $(route -n | head -n 3 | tail -n 1 | awk '{print $8}') | grep inet | awk '{print \$2}'" - - netok(){ - # ping google.com - echo 'Testing DNS settings.' - timeout 1 ping google.com -W 1 -c 1 &>> /dev/null - if (( $? == 0 )); then - echo 'Internet is up.' - return 0 - fi - # ping 8.8.8.8 - echo 'Pinging 8.8.8.8' - ping 8.8.8.8 -W 1 -c 1 &>> /dev/null - if (( $? == 0 )); then - echo 'Issue spoted in DNS settings' - return 0 - fi - # ping gateway - gateway=$(echo $(route -n | sed -n '3p' | awk '{print $2}')) - echo 'Pinging ' $gateway - ping $gateway -W 1 -c 2 &>> /dev/null - if (($? == 0 )); then - echo 'Gateway connectivity issues or being firewalled.' - return 0 - else - echo 'Cant reach default gateway.' - return 0 - fi - # deteemine issue -} - -#alias tldr="rm -r /home/viktor/.tldr_cache/ &> /dev/null; tldr" -alias sl=ls -alias vimrc="vim ~/.vimrc" -alias zshrc="vim ~/.zshrc" -alias f="free -h" -alias h="sudo htop" -alias a="sudo atop" -alias e="exa -bghHliS" -alias n="sudo nethogs" -alias hosts="sudo vim /etc/hosts" - -# Source: -# https://wiki.archlinux.org/index.php/Streaming_to_twitch.tv - streaming() { - youtube_key="k1ms-wpmc-v652-7rjr" # Ancient, not used anymore - twitch_key="live_56376159_CCAGv99vT0rr3QwiBiMuDAdoPcYB5N" # Ancient, not user anymore - - if [ "$#" -ne 1 ]; then - echo "Choose yt/tw" - return 1 - fi - - if [ "$1" = "yt" ]; then - STREAM_KEY=$youtube_key - STREAM_URI="rtmp://a.rtmp.youtube.com/live2/$STREAM_KEY" - elif [ "$1" = "tw" ]; then - STREAM_KEY=$twitch_key - SERVER="live-fra" # twitch server in frankfurt, see http://bashtech.net/twitch/ingest.php for list - STREAM_URI="rtmp://$SERVER.twitch.tv/app/$STREAM_KEY" - else - echo "Invalid media\nChoose yt/tw" - exit 1 - fi - - # INRES="1920x1080" # input resolution - # OUTRES="1920x1080" # output resolution - INRES="$(xdpyinfo | awk '/dimensions/{print $2}')" - # OUTRES="$(xdpyinfo | awk '/dimensions/{print $2}')" - # OUTRES="1280x720" - OUTRES="2560x1440" - # OUTRES="3840x2160" - FPS="15" # target FPS - GOP="29" # i-frame interval, should be double of FPS, - GOPMIN="15" # min i-frame interval, should be equal to fps, - THREADS="0" # max 6 - CBR="4000k" # constant bitrate (yuvj444p) - QUALITY="ultrafast" # one of the many FFMPEG preset - AUDIO_RATE="44100" - # STREAM_KEY="$1" # use the terminal command Streaming streamkeyhere to stream your video to twitch or justin - - ffmpeg -thread_queue_size 512 -f x11grab -s "$INRES" -r "$FPS" -i :0.0 -f alsa -i pulse -f flv -ac 2 -ar $AUDIO_RATE \ - -vcodec libx264 -g $GOP -keyint_min $GOPMIN -b:v $CBR -minrate $CBR -maxrate $CBR -pix_fmt yuv444p\ - -s $OUTRES -preset $QUALITY -tune zerolatency -acodec libmp3lame -threads $THREADS -strict normal \ - -bufsize $CBR $STREAM_URI - } -alias gg="xset dpms force off" - -alias hib="sudo systemctl hibernate" -# where systemctl doesn't work - # hib(){ - # # sudo swapon /dev/kubuntu-vg/swap_1 2&>/dev/null - # # sudo systemctl hibernate - # # sudo swapoff /dev/kubuntu-vg/swap_1 2&>/dev/null - # sudo swapon -a - # /bin/lock - # sleep 2 - # sudo s2disk 2>1 > /dev/null -# } - -alias tricks="vi ~/tricks/tricks.txt" -alias ftricks="vi ~/tricks/fedora.txt" -alias xo="xdg-open" -alias time='"time"' # Disable bash builit -alias vix="vim -X" # Fast vim startup wihtout x (no ystem clipboard) -alias reso="xrandr --output HDMI-1 --scale-from 1920x1080" -alias zoomit="gromit-mpx" -alias dk="docker" - -alias lk="sudo logkeys -u --start --output /home/viktor/tt --device /dev/input/event4" # integrated keyboard -alias lk1="sudo logkeys --start --output /home/viktor/tt --device /dev/input/event17" # usb keyboard - - psave() { - sudo service bluetooth stop - sudo service vmware-workstation-server stop - sudo service vmware stop - sudo service ModemManager stop -} - - camelcase() { - perl -pe 's#(_|^)(.)#\u$2#g' -} - - rem_known() { - "ssh-keygen -f '/home/viktor/.ssh/known_hosts' -R $1" -} - -alias s="ssh" -ytplaylist(){ - # if error try updating youtube-dl with: sudo youtube-dl -U - # youtube-dl -o - $1 -f best | /snap/bin/vlc - - youtube-dl -o - -f best $@ | vlc - - # youtube-dl --get-id "$1" | awk '{print "https://www.youtube.com/watch?v=" $0;}' | /snap/bin/vlc - -} - -function certinfo { - # curl --insecure -v "$1" 2>&1; - curl --insecure -v https://"$1" 2>&1 | awk 'BEGIN { cert=0 } /^\* SSL connection/ { cert=1 } /^\*/ { if (cert) print }'; -} - -alias speedtest="curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py |python -" -alias backupnas="rsync -az --progress --delete /home nas:/volume1/Backup/Viki/laptop/yuhu-fedora; rsync -az --progress --delete /opt nas:/volume1/Backup/Viki/laptop/yuhu-fedora" - -function c(){ - # pass any arguments to gcc and afterwards run executable - gcc "$@" && ./a.out -} - -function dang_gcc(){ - gcc "$@" -fno-stack-protector -z execstack -} - -function encrypt() { - tar -czvf $1.tar.gz $1 && \ - gpg --symmetric --armor $1.tar.gz && \ - echo "Deleting $1 and $1.tar.gz" && \ - rm -rf $1 $1.tar.gz -} - -function decrypt() { - gpg --decrypt $1 | tar xzvf - -} - -# use avr-gcc for latfortuna, but gcc works as well -function make_tags() { -avr-gcc -M $* | sed -e 's/[\\ ]/\n/g' | \ - sed -e '/^$/d' -e '/\.o:[ \t]*$/d' | ctags -L - --c++-kinds=+p --fields=+iaS --extra=+q -} -#alias server="python3 -m http.server --bind 0.0.0.0 8000" -alias server="/opt/miniserve-linux" -alias gr="go run ." -alias hg="hugo -D server --bind 0.0.0.0" -alias logout="qdbus org.kde.ksmserver /KSMServer logout 0 0 0" -alias sucss="cd ~/pentesting/sucss-19 && workon sucss-playground-webapp" -alias i="sudo iotop" -alias ssucss="ssh sucss.ecs.soton.ac.uk" -alias gpc="globalprotect connect; sudo sed -i '1 i\\nameserver 152.78.110.110' /etc/resolv.conf" -alias gpd="globalprotect disconnect; sudo sed -i '1d' /etc/resolv.conf" - -function whoishome() { - # echo "Finding connected devices..." - ips=$(nmap -sn 192.168.0.1/24 | grep for | awk '{print $5}') - - # echo "Getting entries from ARP table..." - # Get entries in arp table - python3 -c ' -import sys -users={ - "C8:21:58:98:29:25": "lubo-laptop", - "18:F0:E4:2A:CB:B0": "lubo-phone", - "2C:0E:3D:A7:C1:19": "viktor-phone", - "48:89:E7:18:0E:66": "viktor-laptop", - "A0:32:99:C4:0E:38": "nasko-phone", - "44:03:2C:6B:04:5E": "nasko-laptop", - "48:01:C5:39:A6:3D": "ioana-phone", - "F4:0F:24:2B:FE:14": "ioana-laptop", - "50:EB:71:23:BC:11": "gabi-laptop", - "FE:43:0A:04:03:BA": "gabi-phone", -} -# print("Connected device: ") -for line in sys.argv[1].split("\n"): - ip = line.split()[1].replace("(", "").replace(")", "") - mac = line.split()[3].upper() - if mac in users: - print(f"{users[mac]}:{ip}") -' "$(arp -a | grep -v incomplete)" -} - -alias wa="watch sensors" -alias gtop="sudo intel_gpu_top" - -ZSH_AUTOSUGGEST_STRATEGY=(history completion) -bindkey '^[0' autosuggest-accept; -# bindkey '^[9' forward-word; -bindkey '^[9' autosuggest-fetch; -# bindkey '^[9' autosuggest-clear; -#bindkey '^ ' autosuggest-fetch -alias sp="snapper -c home" - -function snp(){ - # Runs a command wrapped in btrfs snapper pre-post snapshots. - # Usage: $ snp - # e.g.: $ snp dnf install htop - - cmd="$@" - - snapshot_nbr=$(snapper -c home create --type=pre --cleanup-algorithm=number --print-number --description="${cmd}") - # snapshot_nbr=$(sudo snapper create --type=pre --cleanup-algorithm=number --print-number --description="${cmd}") - - eval "$cmd" - - snapshot_nbr=$(snapper -c home create --type=post --cleanup-algorithm=number --print-number --pre-number="$snapshot_nbr") - # snapshot_nbr=$(sudo snapper create --type=post --cleanup-algorithm=number --print-number --pre-number="$snapshot_nbr") -} - -function waitfor() { - while pidof $1 > /dev/null; do sleep 2; done; -} -alias toclip="xclip -selection clipboard" -alias clearsessions="rm -rf ~/.vim/tmp/sessions/*" -#alias restore_virtualenv_post_scripts="find /home/.snapshots/337/snapshot/viktor/.virtualenvs -name 'postactivate' | sed 's/\/home\/.snapshots\/337\/snapshot\/viktor\///' | xargs -I % rsync -va /home/.snapshots/337/snapshot/viktor/% ~/" - -# `clear` can be seen and flicker is annoying -# function watch() { -# while sleep 1; do -# clear; -# ${SHELL-/bin/sh} -c "$*" -# done; -# } -alias vmon="sudo systemctl start vmware" -alias vmoff="sudo systemctl stop vmware" -alias dkon="sudo systemctl start docker" -alias dkoff="sudo systemctl stop docker" -alias tf="terraform" -alias tfa="tf apply" -function b64() { - echo $1 | base64 -d -} -# alias fuck='sudo $(history -p !!)' -alias fuck='sudo $(fc -ln -1)' -alias curlb='curl -s -o /dev/null -w "%{time_starttransfer}\n" "$@"' -alias nomicautoadjust='while sleep 0.5; do pacmd set-source-volume alsa_input.pci-0000_00_1f.3.analog-stereo 20000; done' - -# Needs to send dbus msg not sure how -# function toggleLidClose() { -# # If action is none, make it suspend and vice-versa -# if grep 'lidAction=0' ~/.config/powermanagementprofilesrc > /dev/null; then -# sed -i 's/lidAction=0/lidAction=1/' ~/.config/powermanagementprofilesrc -# else -# sed -i 's/lidAction=1/lidAction=0/' ~/.config/powermanagementprofilesrc -# fi -# } - -# Games -alias medieval="sh -c 'cd ~/.wine/drive_c/Program\ Files\ \(x86\)/SEGA/Medieval\ II\ Total\ War/ && wine medieval2.exe'" - -alias kb="kubectl" -alias kbp="kubectl get pods" -alias kbpo="kubectl get pods -o wide" -alias kbs="kubectl get svc" -alias kbn="kubectl get nodes -o wide" -alias kbd="kubectl describe pods" -alias kbf="kubectl logs --all-containers --max-log-requests 50 -f" -alias kn="kubens" -function cephpw() { - kubectl -n rook-ceph get secret rook-ceph-dashboard-password -o yaml | grep "password:" | grep -v '{}'| awk '{print $2}' | base64 --decode -} -function kbop() { - kb -n rook-ceph delete pods $(kbp |grep opera | awk '{print $1}') - kb -n rook-ceph logs -f $(kbp |grep operator | awk '{print $1}') -} - -alias k8srole="ansible-playbook -i hosts.yaml linux.yml -e host='10.0.20.100' -t " -function wgon(){ - wg-quick up ~/vpn-certs/viktor.conf - # Add ipv4 precedence because vpn is v4 onyl for now - bash -c "grep -qxF 'precedence ::ffff:0:0/96 100' /etc/gai.conf || echo 'precedence ::ffff:0:0/96 100' | sudo tee -a /etc/gai.conf" - # Add dns if missing - ns_str="nameserver 10.0.20.1 # Added by wgon function" - search_str="search viktorbarzin.lan # Added by wgon function" - resolv_conf="/etc/resolv.conf" - bash -c "grep -qxF '$search_str' $resolv_conf || echo '$search_str' | sudo tee -a $resolv_conf" - bash -c "grep -qxF '$ns_str' $resolv_conf || echo '$ns_str' | sudo sed -i -e '1i $ns_str' $resolv_conf" -} -function wgoff(){ - wg-quick down ~/vpn-certs/viktor.conf - - ns_str="nameserver 10.0.20.1 # Added by wgon function" - search_str="search viktorbarzin.lan # Added by wgon function" - resolv_conf="/etc/resolv.conf" - - # Remove ipv4 precedence because vpn is v4 onyl for now - sudo sed -i '/precedence ::ffff:0:0\/96 100/d' /etc/gai.conf - - sudo sed -i "/$search_str/d" $resolv_conf - sudo sed -i "/$ns_str/d" $resolv_conf -} -function wgs() { - kubectl scale -n wireguard deployment wireguard --replicas=$1 -} -alias wg="sudo wg" -alias svm="et -c 'tmux new -A -s main' 10.0.10.104:2022" -alias calicoctl="kubectl exec -i -n kube-system calicoctl -- /calicoctl" -alias ipcalc="ipcalc --no-decorate" -alias ss-tunnel="snap run shadowsocks-libev.ss-tunnel" -alias ss-local="snap run shadowsocks-libev.ss-local" diff --git a/.gitconfig b/.gitconfig deleted file mode 100644 index 51e8de3..0000000 --- a/.gitconfig +++ /dev/null @@ -1,9 +0,0 @@ -[user] - emal = vbarzin@gmail.com - name = viktorbarzin - email = vbarzin@gmail.com - signingkey = 6AF253F1C94B5F00750FBBD40EB088298288D958 -[push] - default = tracking -[branch] - autosetuprebase = always diff --git a/.tmux.conf.local b/.tmux.conf.local deleted file mode 100644 index 3b7fada..0000000 --- a/.tmux.conf.local +++ /dev/null @@ -1,360 +0,0 @@ -# https://github.com/gpakosz/.tmux -# (‑●‑●)> dual licensed under the WTFPL v2 license and the MIT license, -# without any warranty. -# Copyright 2012— Gregory Pakosz (@gpakosz). - - -# -- navigation ---------------------------------------------------------------- - -# if you're running tmux within iTerm2 -# - and tmux is 1.9 or 1.9a -# - and iTerm2 is configured to let option key act as +Esc -# - and iTerm2 is configured to send [1;9A -> [1;9D for option + arrow keys -# then uncomment the following line to make Meta + arrow keys mapping work -#set -ga terminal-overrides "*:kUP3=\e[1;9A,*:kDN3=\e[1;9B,*:kRIT3=\e[1;9C,*:kLFT3=\e[1;9D" - - -# -- windows & pane creation --------------------------------------------------- - -# new window retains current path, possible values are: -# - true -# - false (default) -tmux_conf_new_window_retain_current_path=false - -# new pane retains current path, possible values are: -# - true (default) -# - false -tmux_conf_new_pane_retain_current_path=true - -# new pane tries to reconnect ssh sessions (experimental), possible values are: -# - true -# - false (default) -tmux_conf_new_pane_reconnect_ssh=false - -# prompt for session name when creating a new session, possible values are: -# - true -# - false (default) -tmux_conf_new_session_prompt=false - - -# -- display ------------------------------------------------------------------- - -# RGB 24-bit colour support (tmux >= 2.2), possible values are: -# - true -# - false (default) -tmux_conf_theme_24b_colour=false - -# window style -tmux_conf_theme_window_fg='default' -tmux_conf_theme_window_bg='default' - -# highlight focused pane (tmux >= 2.1), possible values are: -# - true -# - false (default) -tmux_conf_theme_highlight_focused_pane=false - -# focused pane colours: -tmux_conf_theme_focused_pane_fg='default' -tmux_conf_theme_focused_pane_bg='#0087d7' # light blue - -# pane border style, possible values are: -# - thin (default) -# - fat -tmux_conf_theme_pane_border_style=thin - -# pane borders colours: -tmux_conf_theme_pane_border='#444444' # gray -tmux_conf_theme_pane_active_border='#00afff' # light blue - -# pane indicator colours -tmux_conf_theme_pane_indicator='#00afff' # light blue -tmux_conf_theme_pane_active_indicator='#00afff' # light blue - -# status line style -tmux_conf_theme_message_fg='#000000' # black -tmux_conf_theme_message_bg='#ffff00' # yellow -tmux_conf_theme_message_attr='bold' - -# status line command style ( : Escape) -tmux_conf_theme_message_command_fg='#ffff00' # yellow -tmux_conf_theme_message_command_bg='#000000' # black -tmux_conf_theme_message_command_attr='bold' - -# window modes style -tmux_conf_theme_mode_fg='#000000' # black -tmux_conf_theme_mode_bg='#ffff00' # yellow -tmux_conf_theme_mode_attr='bold' - -# status line style -tmux_conf_theme_status_fg='#8a8a8a' # light gray -tmux_conf_theme_status_bg='#080808' # dark gray -tmux_conf_theme_status_attr='none' - -# terminal title -# - built-in variables are: -# - #{circled_window_index} -# - #{circled_session_name} -# - #{hostname} -# - #{hostname_ssh} -# - #{username} -# - #{username_ssh} -tmux_conf_theme_terminal_title='#h ❐ #S ● #I #W' - -# window status style -# - built-in variables are: -# - #{circled_window_index} -# - #{circled_session_name} -# - #{hostname} -# - #{hostname_ssh} -# - #{username} -# - #{username_ssh} -tmux_conf_theme_window_status_fg='#8a8a8a' # light gray -tmux_conf_theme_window_status_bg='#080808' # dark gray -tmux_conf_theme_window_status_attr='none' -tmux_conf_theme_window_status_format='#I #W' -#tmux_conf_theme_window_status_format='#{circled_window_index} #W' -#tmux_conf_theme_window_status_format='#I #W#{?window_bell_flag,🔔,}#{?window_zoomed_flag,🔍,}' - -# window current status style -# - built-in variables are: -# - #{circled_window_index} -# - #{circled_session_name} -# - #{hostname} -# - #{hostname_ssh} -# - #{username} -# - #{username_ssh} -tmux_conf_theme_window_status_current_fg='#000000' # black -tmux_conf_theme_window_status_current_bg='#00afff' # light blue -tmux_conf_theme_window_status_current_attr='bold' -tmux_conf_theme_window_status_current_format='#I #W' -#tmux_conf_theme_window_status_current_format='#{circled_window_index} #W' -#tmux_conf_theme_window_status_current_format='#I #W#{?window_zoomed_flag,🔍,}' - -# window activity status style -tmux_conf_theme_window_status_activity_fg='default' -tmux_conf_theme_window_status_activity_bg='default' -tmux_conf_theme_window_status_activity_attr='underscore' - -# window bell status style -tmux_conf_theme_window_status_bell_fg='#ffff00' # yellow -tmux_conf_theme_window_status_bell_bg='default' -tmux_conf_theme_window_status_bell_attr='blink,bold' - -# window last status style -tmux_conf_theme_window_status_last_fg='#00afff' # light blue -tmux_conf_theme_window_status_last_bg='default' -tmux_conf_theme_window_status_last_attr='none' - -# status left/right sections separators -# tmux_conf_theme_left_separator_main='' -# tmux_conf_theme_left_separator_sub='|' -# tmux_conf_theme_right_separator_main='' -# tmux_conf_theme_right_separator_sub='|' -tmux_conf_theme_left_separator_main='\uE0B0' # /!\ you don't need to install Powerline -tmux_conf_theme_left_separator_sub='\uE0B1' # you only need fonts patched with -tmux_conf_theme_right_separator_main='\uE0B2' # Powerline symbols or the standalone -tmux_conf_theme_right_separator_sub='\uE0B3' # PowerlineSymbols.otf font, see README.md - -# status left/right content: -# - separate main sections with '|' -# - separate subsections with ',' -# - built-in variables are: -# - #{battery_bar} -# - #{battery_hbar} -# - #{battery_percentage} -# - #{battery_status} -# - #{battery_vbar} -# - #{circled_session_name} -# - #{hostname_ssh} -# - #{hostname} -# - #{loadavg} -# - #{pairing} -# - #{prefix} -# - #{root} -# - #{synchronized} -# - #{uptime_y} -# - #{uptime_d} (modulo 365 when #{uptime_y} is used) -# - #{uptime_h} -# - #{uptime_m} -# - #{uptime_s} -# - #{username} -# - #{username_ssh} - -# CPU info -# CPU: #{cpu_icon} #{cpu_percentage} RAM: #{ram_icon} #{ram_percentage} , - -# #(curl wttr.in/Southampton?format=3) , # - for weather -cpu_percentage_format="%3.1f%%" # printf format to use to display percentage -tmux_conf_theme_status_left=' ❐ #S | ↑#{?uptime_y, #{uptime_y}y,}#{?uptime_d, #{uptime_d}d,}#{?uptime_h, #{uptime_h}h,}#{?uptime_m, #{uptime_m}m,} ' -#tmux_conf_theme_status_right='#{prefix}#{pairing}#{synchronized} #{?battery_status, #{battery_status},}#{?battery_bar, #{battery_bar},}#{?battery_percentage, #{battery_percentage},} , %R , %d %b | #{username}#{root} | #{hostname} ' -tmux_conf_theme_status_right=" IP:#(ip route get 8.8.8.8 | head -1 | cut -d' ' -f7) , \ -DNS:#(echo $(cat /etc/resolv.conf | grep 'nameserver [0-9]' | awk '{print $2}')) , \ -Gateway:#(echo $(route -n | sed -n '3p' | awk '{print $2}')) #{prefix}#{pairing} #[fg=green]#($TMUX_PLUGIN_MANAGER_PATH/tmux-mem-cpu-load/tmux-mem-cpu-load --colors --powerline-right --interval 2) , #{?battery_status, #{battery_status},}#{?battery_bar, #{battery_bar},}#{?battery_percentage, #{battery_percentage},} , %R , %d %b | #{username}#{root} | #{hostname}" - - -# status left style -tmux_conf_theme_status_left_fg='#000000,#e4e4e4,#e4e4e4' # black, white , white -tmux_conf_theme_status_left_bg='#ffff00,#ff00af,#00afff' # yellow, pink, white blue -tmux_conf_theme_status_left_attr='bold,none,none' - -# status right style -tmux_conf_theme_status_right_fg='#8a8a8a,#e4e4e4,#000000' # light gray, white, black -tmux_conf_theme_status_right_bg='#080808,#d70000,#e4e4e4' # dark gray, red, white -tmux_conf_theme_status_right_attr='none,none,bold' - -# pairing indicator -tmux_conf_theme_pairing='👓 ' # U+1F453 -tmux_conf_theme_pairing_fg='none' -tmux_conf_theme_pairing_bg='none' -tmux_conf_theme_pairing_attr='none' - -# prefix indicator -tmux_conf_theme_prefix='⌨ ' # U+2328 -tmux_conf_theme_prefix_fg='none' -tmux_conf_theme_prefix_bg='none' -tmux_conf_theme_prefix_attr='none' - -# root indicator -tmux_conf_theme_root='!' -tmux_conf_theme_root_fg='none' -tmux_conf_theme_root_bg='none' -tmux_conf_theme_root_attr='bold,blink' - -# synchronized indicator -tmux_conf_theme_synchronized='🔒' # U+1F512 -tmux_conf_theme_synchronized_fg='none' -tmux_conf_theme_synchronized_bg='none' -tmux_conf_theme_synchronized_attr='none' - -# battery bar symbols -# tmux_conf_battery_bar_symbol_full='◼' -# tmux_conf_battery_bar_symbol_empty='◻' -tmux_conf_battery_bar_symbol_full='♥' -tmux_conf_battery_bar_symbol_empty='·' - -# battery bar length (in number of symbols), possible values are: -# - auto -# - a number, e.g. 5 -tmux_conf_battery_bar_length='auto' - -# battery bar palette, possible values are: -# - gradient (default) -# - heat -# - 'colour_full_fg,colour_empty_fg,colour_bg' -tmux_conf_battery_bar_palette='gradient' -#tmux_conf_battery_bar_palette='#d70000,#e4e4e4,#000000' # red, white, black - -# battery hbar palette, possible values are: -# - gradient (default) -# - heat -# - 'colour_low,colour_half,colour_full' -tmux_conf_battery_hbar_palette='gradient' -#tmux_conf_battery_hbar_palette='#d70000,#ff5f00,#5fff00' # red, orange, green - -# battery vbar palette, possible values are: -# - gradient (default) -# - heat -# - 'colour_low,colour_half,colour_full' -tmux_conf_battery_vbar_palette='gradient' -#tmux_conf_battery_vbar_palette='#d70000,#ff5f00,#5fff00' # red, orange, green - -# symbols used to indicate whether battery is charging or discharging -# tmux_conf_battery_status_charging='↑' # U+2191 -# tmux_conf_battery_status_discharging='↓' # U+2193 -# tmux_conf_battery_status_charging='⚡ ' # U+26A1 -tmux_conf_battery_status_charging='🔌 ' # U+1F50C # if you can't see this, fonts are not working -tmux_conf_battery_status_discharging='🔋 ' # U+1F50B - -# clock style (when you hit + t) -# you may want to use %I:%M %p in place of %R in tmux_conf_theme_status_right -tmux_conf_theme_clock_colour='#00afff' # light blue -tmux_conf_theme_clock_style='24' - - -# -- clipboard ----------------------------------------------------------------- - -# in copy mode, copying selection also copies to the OS clipboard -# - true -# - false (default) -# on macOS, this requires installing reattach-to-user-namespace, see README.md -# on Linux, this requires xsel or xclip -tmux_conf_copy_to_os_clipboard=false - - -# -- user customizations ------------------------------------------------------- -# this is the place to override or undo settings - -# increase history size -#set -g history-limit 10000 - -# start with mouse mode enabled -#set -g mouse on - -# force Vi mode -# really you should export VISUAL or EDITOR environment variable, see manual -set -g status-keys vi -set -g mode-keys vi - -# replace C-b by C-a instead of using both prefixes -set -gu prefix2 -unbind C-a -# unbind C-b -# set -g prefix C-a -# bind C-a send-prefix -set -g prefix M-x -bind M-x send-prefix - -# move status line to top -#set -g status-position top - -bind \\ split-window -h -c "#{pane_current_path}" # Split panes horizontal -bind - split-window -v -c "#{pane_current_path}" # Split panes vertical - -# Use Alt-vim keys without prefix key to switch panes -bind -n M-h select-pane -L -bind -n M-j select-pane -D -bind -n M-k select-pane -U -bind -n M-l select-pane -R -# Use Alt-arrow keys without prefix key to switch panes -bind -n M-Left select-pane -L -bind -n M-Right select-pane -R -bind -n M-Up select-pane -U -bind -n M-Down select-pane -D -set -g mouse on -# to enable mouse scroll, see https://github.com/tmux/tmux/issues/145#issuecomment-150736967 -bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e'" -bind j resize-pane -D 5 -bind k resize-pane -U 5 -bind l resize-pane -R 5 -bind h resize-pane -L 5 - -# Copy to system clipboard using xlip -bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard' -bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard' - -bind-key s set-window-option synchronize-panes\; display-message "synchronize-panes is now #{?pane_synchronized,on,off}" - -set-option -g default-shell /bin/zsh - -set-window-option -g aggressive-resize - -# Putting this in .tmux.conf.local does not work :/ 3.0a -# Custom added - MUST be in the end -# List of plugins -set -g @plugin 'tmux-plugins/tpm' -set -g @plugin 'tmux-plugins/tmux-sensible' - -set -g @plugin 'tmux-plugins/tmux-resurrect' -set -g @resurrect-processes 'vi vim nvim man less more tail top htop' - -set -g @plugin 'tmux-plugins/tmux-continuum' - -#set -g @continuum-restore 'on' -set -g @continuum-restore 'off' - -set -g @plugin 'thewtex/tmux-mem-cpu-load' - -set -g default-command "${SHELL}" - -# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) -run -b '~/.tmux/plugins/tpm/tpm' diff --git a/.vimrc b/.vimrc deleted file mode 100644 index cb52493..0000000 --- a/.vimrc +++ /dev/null @@ -1,486 +0,0 @@ -" Source vimrc on vim startup -" autocmd! VimEnter * source ~/.vimrc - -" Load rename plugin -" so ~/.vim/Rename.vim - -" let g:EclimCompletionMethod = 'omnifunc' -" Java Autocomplete -" let g:acp_behaviorJavaEclimLength=3 -" function MeetsForJavaEclim(context) -" return g:acp_behaviorJavaEclimLength >= 0 && -" \ a:context =~ '\k\.\k\{' . g:acp_behaviorJavaEclimLength . ',}$' -" endfunction -" let g:acp_behavior = { -" \ 'java': [{ -" \ 'command': "\\", -" \ 'completefunc' : 'eclim#java#complete#CodeComplete', -" \ 'meets' : 'MeetsForJavaEclim', -" \ }] -" \ } - -" Rezise splits -"nnoremap :vertical resize -20 - - -" Autoindent html -" autocmd BufWritePre *.html :normal gg=G - -" Remove spaces at end of lines -autocmd BufWritePre * %s/\s\+$//e - -" Fold all with leader + f -nnoremap f :call ToggleFold() - -" Set relative line number and number to see current line number -" set rnu -set number -" Show commands as being written -set showcmd - -" Set syntastic settings -set statusline+=%#warningmsg# -if exists("SyntasticStatuslineFlag") - set statusline+=%{SyntasticStatuslineFlag()} -endif -set statusline+=%* - -" Disables syntastic popup window with messages -" Set both to 1 to turn it on -let g:syntastic_always_populate_loc_list = 1 -let g:syntastic_auto_loc_list = 1 -let g:syntastic_check_on_open = 1 -let g:syntastic_check_on_wq = 0 -" 3 errors is more than enough -let g:syntastic_loc_list_height=3 -nnoremap :SyntasticCheck mypy -" Set xptemplate trigger key to tab -" let g:xptemplate_key = '' - -" Autocomplete with Tab -" inoremap -"inoremap - - -" Rebind key -" I like to have it here becuase it is easier to reach than the default and -" it is next to ``m`` and ``n`` which I use for navigating between tabs. -let mapleader = "," - -" Swap lines -nnoremap k :-1,-1m+0k -nnoremap j :+0,+0m+1 -vnoremap k :m '<-2gv=gv -vnoremap j :m '>+1gv=gv - -" Enable folding with spacebar -nnoremap za - -" Make surrounding with various characters easier -nmap ' ysiW' -nmap " ysiW" -nmap 0 ysiW) - -" Go to normal mode by tapping jk or kj -inoremap kj -inoremap jk - -" Easier buffer closing -nnoremap q :bd - -" Close splits instead of buffers -" nnoremap q :q - -" Swap to previous buffer -nnoremap :b# - -" Map backspace to delete -nnoremap h -vnoremap d - -" Save with s in normal and insert mode -noremap s :update -inoremap s :update -" Sudo save with S -noremap S :w !sudo tee % > /dev/null -" map sort function to a key -vnoremap s :sort - -" Writes to all buffers when switching to another buffer -set autowrite - -" Enable tabs plugin -let g:airline#extensions#tabline#enabled = 1 -let g:airline#extensions#tabline#left_sep = ' ' -let g:airline#extensions#tabline#left_alt_sep = '|' -" let g:airline_left_sep='>' -" let g:airline_right_sep='<' -" let g:airline_detect_modified=1 -let g:airline_powerline_fonts=1 -" let g:airline_section_b = '%{strftime("%c")}' -" let g:airline_section_y = 'BN: %{bufnr("%")} FT: %y' -let g:airline#extensions#ale#enabled = 1 - -" Enable wildmenu which is an enhanced command completion -" -set wildmenu -" Better copy & paste -" When you want to paste large blocks of code into vim, press F2 before you -" paste. At the bottom you should see ``-- INSERT (paste) --``. - -set pastetoggle= -set clipboard=unnamed - -" Mouse and backspace -set mouse=a " on OSX press ALT and click -set bs=2 " make backspace behave like normal again - -" Remember the cursor last position -if has("autocmd") - au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif -endif - -" Set VIMHOME -if has('win32') || has ('win64') - let $VIMHOME = $VIM."/vimfiles" - else - let $VIMHOME = $HOME."/.vim" - endif - -" Bind nohl -" Removes highlight of your last search -" ```` stands for ``CTRL`` and therefore ```` stands for ``CTRL+n`` -noremap :nohl -vnoremap :nohl -"inoremap :nohl -noremap :syntax sync fromstart -vnoremap :syntax sync fromstart - -" Tab switching -noremap :b# -vnoremap :b# -"inoremap :b# - -" Quicksave command -" noremap :update -" vnoremap :update -" inoremap :update - -" bind Ctrl+ keys to move around the windows, instead of using -" Ctrl+w + -" Every unnecessary keystroke that can be saved is good for your health :) -"nmap :wincmd j -map j -map k -map l -map h - -" easier moving between tabs -map m ;bn -map n ;bp - -" Create empty buffer and open it -map t :enew - -" easier moving of code blocks -" Try to go into visual mode (v), thenselect several lines of code here and -" then press `>` several times. -vnoremap < >gv " better indentation - -" Show whitespace -" MUST be inserted BEFORE the colorscheme command -autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red -au InsertLeave * match ExtraWhitespace /\s\+$/ - -" Color scheme -" mkdir -p ~/.vim/colors && cd ~/.vim/colors -" wget -O wombat256mod.vim -" http://www.vim.org/scripts/download_script.php?src_id=13400 -set t_Co=256 -color wombat256mod -" color ronakg -" color mayansmoke -" color github - -" Spelling -" set spell -" set complete+=kpspell - -" Enable syntax highlighting -" You need to reload this file for the change to apply -filetype off -filetype plugin indent on -syntax on - -" In visual mode searches for the selected word -vnoremap // y/" - -" Showing line numbers and length -set tw=0 " width of document (used by gd) -" set tw=120 " width of document (used by gd) -set nowrap " don't automatically wrap on load -set fo-=t " don't automatically wrap text when typing -" set colorcolumn=80 -set colorcolumn=0 -" highlight ColorColumn ctermbg=233 -highlight ColorColumn ctermbg=001 - - -" Useful settings -set history=700 -set undolevels=700 - -" Real programmers don't use TABs but spaces -set tabstop=4 -set softtabstop=4 -set shiftwidth=4 -set shiftround -set expandtab - -" Make search case insensitive -set hlsearch -set incsearch -set ignorecase -set smartcase - -" Disable stupid backup and swap files - they trigger too many events -" for file system watchers -"set nobackup -"set nowritebackup -"set noswapfile - -" Backup files are great so lets keep them in 1 place -" Make sure you have ~/vimtmp/ folder. In the future will -" move /vimtmp/ in $VIMHOME -set backupdir=~/.vim/tmp//,. -set directory=~/.vim/tmp//,. -set dir=~/.vim/tmp//,. -set undodir=~/.vim/tmp/undo// - -" Setup Pathogen to manage your plugins -" mkdir -p ~/.vim/autoload ~/.vim/bundle -" curl -so ~/.vim/autoload/pathogen.vim -" https://raw.githubusercontent.com/tpope/vim-pathogen/master/autoload/pathogen.vim -" Now you can install any plugin into a .vim/bundle/plugin-name/ folder - -" Pathogen does not work in combatability mode so disable -set nocp -" let g:pathogen_disabled = ["syntastic"] -call pathogen#infect() - - -" Settings for vim-powerline -" cd ~/.vim/bundle -" git clone git://github.com/Lokaltog/vim-powerline.git -set laststatus=2 - -" Settings for ctrlp -" cd ~/.vim/bundle -" git clone https://github.com/kien/ctrlp.vim.git -let g:ctrlp_max_height = 30 -let g:ctrlp_working_path_mode = 'ar' -set wildignore+=*.pyc -set wildignore+=*_build/* -set wildignore+=*/coverage/* - -" Settings for python-mode -" Note: I'm no longer using this. Leave this commented out -" and uncomment the part about jedi-vim instead -" cd ~/.vim/bundle -" git clone https://github.com/klen/python-mode -"" map g :call RopeGotoDefinition() -"" let ropevim_enable_shortcuts = 1 -"" let g:pymode_rope_goto_def_newwin = "vnew" -" let g:pymode_rope_extended_complete = 1 -"" let g:pymode_breakpoint = 0 -"" let g:pymode_syntax = 1 -"" let g:pymode_syntax_builtin_objs = 0 -"" let g:pymode_syntax_builtin_funcs = 0 -"" map b Oimport ipdb; ipdb.set_trace() # BREAKPOINT -" let g:SuperTabDefaultCompletionType = "" -" Settings for jedi-vim -" cd ~/.vim/bundle -" git clone git://github.com/davidhalter/jedi-vim.git -" let g:jedi#usages_command = "z" -" let g:jedi#popup_on_dot = 1 -" let g:jedi#popup_select_first = 0 -" let g:jedi#force_py_version = 3 -" let g:jedi#completions_command = '.' -" let g:jedi#show_call_signatures = 1 -" map b Oimport ipdb; ipdb.set_trace() # BREAKPOINT - -" Map C-a to select entire file -"nnoremap ggVG - -" Real vimmers dont use those -noremap -noremap -noremap -noremap - -" Do splits with Leader-\ and Leader-- -" nnoremap :vsp -" nnoremap :sp -noremap \ :vsp -noremap - :sp - -" NERDTree settings -" Open NERDTree by default -"autocmd VimEnter * NERDTree -"autocmd VimEnter * wincmd p -" Toggle NEDRTree plugin -noremap :NERDTreeToggle -let NERDTreeIgnore = ['\.pyc$', '__pycache__', '.mypy_cache', '.pytest_cache'] -let NERDTreeShowHidden=1 - -" Better navigating through omnicomplete option list -" See -"http://stackoverflow.com/questions/2170023/how-to-map-keys-for-popup-menu-in-vim -set completeopt=longest,menuone -function! OmniPopup(action) - if pumvisible() - if a:action == 'j' - return "\" - elseif a:action == 'k' - return "\" - endif - endif - return a:action -endfunction - -" Python folding -" mkdir -p ~/.vim/ftplugin -" wget -O ~/.vim/ftplugin/python_editing.vim -"http://www.vim.org/scripts/download_script.php?src_id=5492 -set foldenable - -" Keep undo history even after closing file -set undofile - -" Setups template files (more on this - https://shapeshed.com/vim-templates/) -if has("autocmd") - augroup templates - autocmd BufNewFile *.py 0r ~/.vim/templates/skeleton.py - autocmd BufNewFile *.sh 0r ~/.vim/templates/skeleton.sh - augroup END -endif - -" comment out highlighted lines according to file type -" put a line like the following in your ~/.vim/filetype.vim file -" and remember to turn on filetype detection: filetype on -" au! BufRead,BufNewFile *.sh,*.tcl,*.php,*.pl let Comment="#" -" if the comment character for a given filetype happens to be @ -" then use let Comment="\@" to avoid problems... -" function! CommentLines() -" "let Comment="#" " shell, tcl, php, perl -" exe ":s@^@".g:Comment."@g" -" exe ":s@$@".g:EndComment."@g" -" endfunction -" " map visual mode keycombo 'co' to this function -" vmap co :call CommentLines() - -" Encryption algo (vim -x file) -set cm=blowfish2 - -" Improve perfomance with long lines -set synmaxcol=200 - -set autoread - -" Autosave -" augroup autoSaveAndRead -" autocmd! -" autocmd TextChanged,InsertLeave,FocusLost * silent! wall -" autocmd CursorHold * silent! checktime -" augroup END - -" Lion alignment operator config (see https://github.com/tommcdo/vim-lion) -let b:lion_squeeze_spaces = 1 - -set showmatch -set matchtime=3 - -" Fold functions in bash -let g:sh_fold_enabled=3 - -" Recompute syntax highlighting -nnoremap :syntax sync fromstart - -autocmd FileType markdown syntax sync fromstart - -set cursorline -" Minimal number of lines before scrolling -set scrolloff=3 -set sidescrolloff=3 - -" Easier line joining -if v:version > 703 || v:version == 703 && has('patch541') - set formatoptions+=j -endif - -set relativenumber - -" nnoremap Q :qa - -" Remap ; to be : - save 1 key press :P -nnoremap ; : -nnoremap : ; - -" Gundo docs https://sjl.bitbucket.io/gundo.vim/ -let g:gundo_prefer_python3 = 1 -nnoremap :GundoToggle - -" Auto encrypt files related to courseworks at uni -augroup encrypted - autocmd BufNewFile */soton/*/coursework* :X -augroup END - -" SEttings for Go -let g:neocomplete#enable_at_startup = 1 " DO NOT MOVE in another file -let g:xptemplate_key = '' - -" Put these lines at the very end of your vimrc file. - -" Load all plugins now. -" Plugins need to be added to runtimepath before helptags can be generated. -packloadall -" Load all of the helptags now, after plugins have been loaded. -" All messages and errors will be ignored. -silent! helptags ALL - -let g:ctrlp_custom_ignore = 'node_modules\|DS_Store\|git' - -au BufNewFile,BufRead,BufReadPost *.thrift set syntax=thrift - -" Autosave sessions -fu! SaveSess() - execute 'mksession! ' . '~/.vim/tmp/sessions/' . substitute(getcwd(), "/", '!', "g"). '.session.vim' -endfunction - -fu! RestoreSess() - let l:name = expand('~/.vim/tmp/sessions/') . substitute(getcwd(), "/", '!', "g") . '.session.vim' - if filereadable(l:name) - execute 'so ' . l:name - endif -endfunction - -autocmd VimLeave,BufWritePost * call SaveSess() -" autocmd VimEnter * nested call RestoreSess() -nnoremap r :call RestoreSess() - -set updatetime=100 - -" highlight GitGutterDelete guifg=#990000 ctermfg=1 -" highlight GitGutterAdd guifg=#009900 ctermfg=2 -" highlight GitGutterChange guifg=#997c00 ctermfg=3 - -" Move up and down in autocomplete with and -" inoremap ("\") -" inoremap ("\") -" inoremap pumvisible() ? '' : " pumvisible is slow -" inoremap k pumvisible() ? '' : 'k' -" -" inoremap '' -" inoremap '' -" let g:pymode=0 diff --git a/.virtualenvwrapper.sh b/.virtualenvwrapper.sh deleted file mode 100755 index 2104cb4..0000000 --- a/.virtualenvwrapper.sh +++ /dev/null @@ -1,1352 +0,0 @@ -# -*- mode: shell-script -*- -# -# Shell functions to act as wrapper for Ian Bicking's virtualenv -# (http://pypi.python.org/pypi/virtualenv) -# -# -# Copyright Doug Hellmann, All Rights Reserved -# -# Permission to use, copy, modify, and distribute this software and its -# documentation for any purpose and without fee is hereby granted, -# provided that the above copyright notice appear in all copies and that -# both that copyright notice and this permission notice appear in -# supporting documentation, and that the name of Doug Hellmann not be used -# in advertising or publicity pertaining to distribution of the software -# without specific, written prior permission. -# -# DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -# EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR -# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -# USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. -# -# -# Project home page: http://www.doughellmann.com/projects/virtualenvwrapper/ -# -# -# Setup: -# -# 1. Create a directory to hold the virtual environments. -# (mkdir $HOME/.virtualenvs). -# 2. Add a line like "export WORKON_HOME=$HOME/.virtualenvs" -# to your .bashrc. -# 3. Add a line like "source /path/to/this/file/virtualenvwrapper.sh" -# to your .bashrc. -# 4. Run: source ~/.bashrc -# 5. Run: workon -# 6. A list of environments, empty, is printed. -# 7. Run: mkvirtualenv temp -# 8. Run: workon -# 9. This time, the "temp" environment is included. -# 10. Run: workon temp -# 11. The virtual environment is activated. -# - -# Locate the global Python where virtualenvwrapper is installed. -if [ "$VIRTUALENVWRAPPER_PYTHON" = "" ] -then - VIRTUALENVWRAPPER_PYTHON="$(command \which python)" -fi - -# Set the name of the virtualenv app to use. -if [ "$VIRTUALENVWRAPPER_VIRTUALENV" = "" ] -then - VIRTUALENVWRAPPER_VIRTUALENV="virtualenv" -fi - -# Set the name of the virtualenv-clone app to use. -if [ "$VIRTUALENVWRAPPER_VIRTUALENV_CLONE" = "" ] -then - VIRTUALENVWRAPPER_VIRTUALENV_CLONE="virtualenv-clone" -fi - -# Define script folder depending on the platorm (Win32/Unix) -VIRTUALENVWRAPPER_ENV_BIN_DIR="bin" -if [ "$OS" = "Windows_NT" ] && ([ "$MSYSTEM" = "MINGW32" ] || [ "$MSYSTEM" = "MINGW64" ]) -then - # Only assign this for msys, cygwin use standard Unix paths - # and its own python installation - VIRTUALENVWRAPPER_ENV_BIN_DIR="Scripts" -fi - -# Let the user override the name of the file that holds the project -# directory name. -if [ "$VIRTUALENVWRAPPER_PROJECT_FILENAME" = "" ] -then - export VIRTUALENVWRAPPER_PROJECT_FILENAME=".project" -fi - -# Let the user tell us they never want to cd to projects -# automatically. -export VIRTUALENVWRAPPER_WORKON_CD=${VIRTUALENVWRAPPER_WORKON_CD:-1} - -# Remember where we are running from. -if [ -z "$VIRTUALENVWRAPPER_SCRIPT" ] -then - if [ -n "$BASH" ] - then - export VIRTUALENVWRAPPER_SCRIPT="$BASH_SOURCE" - elif [ -n "$ZSH_VERSION" ] - then - export VIRTUALENVWRAPPER_SCRIPT="$0" - else - export VIRTUALENVWRAPPER_SCRIPT="${.sh.file}" - fi -fi - -# Portable shell scripting is hard, let's go shopping. -# -# People insist on aliasing commands like 'cd', either with a real -# alias or even a shell function. Under bash and zsh, "builtin" forces -# the use of a command that is part of the shell itself instead of an -# alias, function, or external command, while "command" does something -# similar but allows external commands. Under ksh "builtin" registers -# a new command from a shared library, but "command" will pick up -# existing builtin commands. We need to use a builtin for cd because -# we are trying to change the state of the current shell, so we use -# "builtin" for bash and zsh but "command" under ksh. -function virtualenvwrapper_cd { - if [ -n "$BASH" ] - then - builtin \cd "$@" - elif [ -n "$ZSH_VERSION" ] - then - builtin \cd -q "$@" - else - command \cd "$@" - fi -} - -function virtualenvwrapper_expandpath { - if [ "$1" = "" ]; then - return 1 - else - "$VIRTUALENVWRAPPER_PYTHON" -c "import os,sys; sys.stdout.write(os.path.normpath(os.path.expanduser(os.path.expandvars(\"$1\")))+'\n')" - return 0 - fi -} - -function virtualenvwrapper_absolutepath { - if [ "$1" = "" ]; then - return 1 - else - "$VIRTUALENVWRAPPER_PYTHON" -c "import os,sys; sys.stdout.write(os.path.abspath(\"$1\")+'\n')" - return 0 - fi -} - -function virtualenvwrapper_derive_workon_home { - typeset workon_home_dir="$WORKON_HOME" - - # Make sure there is a default value for WORKON_HOME. - # You can override this setting in your .bashrc. - if [ "$workon_home_dir" = "" ] - then - workon_home_dir="$HOME/.virtualenvs" - fi - - # If the path is relative, prefix it with $HOME - # (note: for compatibility) - if echo "$workon_home_dir" | (unset GREP_OPTIONS; command \grep '^[^/~]' > /dev/null) - then - workon_home_dir="$HOME/$WORKON_HOME" - fi - - # Only call on Python to fix the path if it looks like the - # path might contain stuff to expand. - # (it might be possible to do this in shell, but I don't know a - # cross-shell-safe way of doing it -wolever) - if echo "$workon_home_dir" | (unset GREP_OPTIONS; command \egrep '([\$~]|//)' >/dev/null) - then - # This will normalize the path by: - # - Removing extra slashes (e.g., when TMPDIR ends in a slash) - # - Expanding variables (e.g., $foo) - # - Converting ~s to complete paths (e.g., ~/ to /home/brian/ and ~arthur to /home/arthur) - workon_home_dir="$(virtualenvwrapper_expandpath "$workon_home_dir")" - fi - - echo "$workon_home_dir" - return 0 -} - -# Check if the WORKON_HOME directory exists, -# create it if it does not -# seperate from creating the files in it because this used to just error -# and maybe other things rely on the dir existing before that happens. -function virtualenvwrapper_verify_workon_home { - RC=0 - if [ ! -d "$WORKON_HOME/" ] - then - if [ "$1" != "-q" ] - then - echo "NOTE: Virtual environments directory $WORKON_HOME does not exist. Creating..." 1>&2 - fi - mkdir -p "$WORKON_HOME" - RC=$? - fi - return $RC -} - -#HOOK_VERBOSE_OPTION="-q" - -# Function to wrap mktemp so tests can replace it for error condition -# testing. -function virtualenvwrapper_mktemp { - command \mktemp "$@" -} - -# Expects 1 argument, the suffix for the new file. -function virtualenvwrapper_tempfile { - # Note: the 'X's must come last - typeset suffix=${1:-hook} - typeset file - - file="$(virtualenvwrapper_mktemp -t virtualenvwrapper-$suffix-XXXXXXXXXX)" - touch "$file" - if [ $? -ne 0 ] || [ -z "$file" ] || [ ! -f "$file" ] - then - echo "ERROR: virtualenvwrapper could not create a temporary file name." 1>&2 - return 1 - fi - echo $file - return 0 -} - -# Run the hooks -function virtualenvwrapper_run_hook { - typeset hook_script - typeset result - - hook_script="$(virtualenvwrapper_tempfile ${1}-hook)" || return 1 - - # Use a subshell to run the python interpreter with hook_loader so - # we can change the working directory. This avoids having the - # Python 3 interpreter decide that its "prefix" is the virtualenv - # if we happen to be inside the virtualenv when we start. - ( \ - virtualenvwrapper_cd "$WORKON_HOME" && - "$VIRTUALENVWRAPPER_PYTHON" -m 'virtualenvwrapper.hook_loader' \ - $HOOK_VERBOSE_OPTION --script "$hook_script" "$@" \ - ) - result=$? - - if [ $result -eq 0 ] - then - if [ ! -f "$hook_script" ] - then - echo "ERROR: virtualenvwrapper_run_hook could not find temporary file $hook_script" 1>&2 - command \rm -f "$hook_script" - return 2 - fi - # cat "$hook_script" - source "$hook_script" - elif [ "${1}" = "initialize" ] - then - cat - 1>&2 <&2 - return 1 - fi - if [ ! -e "$exe_path" ] - then - echo "ERROR: Found $1 in path as \"$exe_path\" but that does not exist" >&2 - return 1 - fi - return 0 -} - - -# Verify that virtualenv is installed and visible -function virtualenvwrapper_verify_virtualenv { - virtualenvwrapper_verify_resource $VIRTUALENVWRAPPER_VIRTUALENV -} - - -function virtualenvwrapper_verify_virtualenv_clone { - virtualenvwrapper_verify_resource $VIRTUALENVWRAPPER_VIRTUALENV_CLONE -} - - -# Verify that the requested environment exists -function virtualenvwrapper_verify_workon_environment { - typeset env_name="$1" - if [ ! -d "$WORKON_HOME/$env_name" ] - then - echo "ERROR: Environment '$env_name' does not exist. Create it with 'mkvirtualenv $env_name'." >&2 - return 1 - fi - return 0 -} - -# Verify that the active environment exists -function virtualenvwrapper_verify_active_environment { - if [ ! -n "${VIRTUAL_ENV}" ] || [ ! -d "${VIRTUAL_ENV}" ] - then - echo "ERROR: no virtualenv active, or active virtualenv is missing" >&2 - return 1 - fi - return 0 -} - -# Help text for mkvirtualenv -function virtualenvwrapper_mkvirtualenv_help { - echo "Usage: mkvirtualenv [-a project_path] [-i package] [-r requirements_file] [virtualenv options] env_name" - echo - echo " -a project_path" - echo - echo " Provide a full path to a project directory to associate with" - echo " the new environment." - echo - echo " -i package" - echo - echo " Install a package after the environment is created." - echo " This option may be repeated." - echo - echo " -r requirements_file" - echo - echo " Provide a pip requirements file to install a base set of packages" - echo " into the new environment." - echo; - echo 'virtualenv help:'; - echo; - "$VIRTUALENVWRAPPER_VIRTUALENV" $@; -} - -# Create a new environment, in the WORKON_HOME. -# -# Usage: mkvirtualenv [options] ENVNAME -# (where the options are passed directly to virtualenv) -# -#:help:mkvirtualenv: Create a new virtualenv in $WORKON_HOME -function mkvirtualenv { - typeset -a in_args - typeset -a out_args - typeset -i i - typeset tst - typeset a - typeset envname - typeset requirements - typeset packages - typeset interpreter - typeset project - - in_args=( "$@" ) - - if [ -n "$ZSH_VERSION" ] - then - i=1 - tst="-le" - else - i=0 - tst="-lt" - fi - while [ $i $tst $# ] - do - a="${in_args[$i]}" - # echo "arg $i : $a" - case "$a" in - -a) - i=$(( $i + 1 )) - project="${in_args[$i]}" - if [ ! -d "$project" ] - then - echo "Cannot associate project with $project, it is not a directory" 1>&2 - return 1 - fi - project="$(virtualenvwrapper_absolutepath ${project})";; - -h|--help) - virtualenvwrapper_mkvirtualenv_help $a; - return;; - -i) - i=$(( $i + 1 )); - packages="$packages ${in_args[$i]}";; - -p|--python*) - if echo "$a" | grep -q "=" - then - interpreter="$(echo "$a" | cut -f2 -d=)" - else - i=$(( $i + 1 )) - interpreter="${in_args[$i]}" - fi;; - -r) - i=$(( $i + 1 )); - requirements="${in_args[$i]}"; - requirements="$(virtualenvwrapper_expandpath "$requirements")";; - *) - if [ ${#out_args} -gt 0 ] - then - out_args=( "${out_args[@]-}" "$a" ) - else - out_args=( "$a" ) - fi;; - esac - i=$(( $i + 1 )) - done - - if [ ! -z $interpreter ] - then - out_args=( "--python=$interpreter" ${out_args[@]} ) - fi; - - set -- "${out_args[@]}" - - eval "envname=\$$#" - virtualenvwrapper_verify_workon_home || return 1 - virtualenvwrapper_verify_virtualenv || return 1 - ( - [ -n "$ZSH_VERSION" ] && setopt SH_WORD_SPLIT - virtualenvwrapper_cd "$WORKON_HOME" && - "$VIRTUALENVWRAPPER_VIRTUALENV" $VIRTUALENVWRAPPER_VIRTUALENV_ARGS "$@" && - [ -d "$WORKON_HOME/$envname" ] && \ - virtualenvwrapper_run_hook "pre_mkvirtualenv" "$envname" - ) - typeset RC=$? - [ $RC -ne 0 ] && return $RC - - # If they passed a help option or got an error from virtualenv, - # the environment won't exist. Use that to tell whether - # we should switch to the environment and run the hook. - [ ! -d "$WORKON_HOME/$envname" ] && return 0 - - # If they gave us a project directory, set it up now - # so the activate hooks can find it. - if [ ! -z "$project" ] - then - setvirtualenvproject "$WORKON_HOME/$envname" "$project" - RC=$? - [ $RC -ne 0 ] && return $RC - fi - - # Now activate the new environment - workon "$envname" - - if [ ! -z "$requirements" ] - then - pip install -r "$requirements" - fi - - for a in $packages - do - pip install $a - done - - virtualenvwrapper_run_hook "post_mkvirtualenv" -} - -#:help:rmvirtualenv: Remove a virtualenv -function rmvirtualenv { - virtualenvwrapper_verify_workon_home || return 1 - if [ ${#@} = 0 ] - then - echo "Please specify an enviroment." >&2 - return 1 - fi - - # support to remove several environments - typeset env_name - # Must quote the parameters, as environments could have spaces in their names - for env_name in "$@" - do - echo "Removing $env_name..." - typeset env_dir="$WORKON_HOME/$env_name" - if [ "$VIRTUAL_ENV" = "$env_dir" ] - then - echo "ERROR: You cannot remove the active environment ('$env_name')." >&2 - echo "Either switch to another environment, or run 'deactivate'." >&2 - return 1 - fi - - if [ ! -d "$env_dir" ]; then - echo "Did not find environment $env_dir to remove." >&2 - fi - - # Move out of the current directory to one known to be - # safe, in case we are inside the environment somewhere. - typeset prior_dir="$(pwd)" - virtualenvwrapper_cd "$WORKON_HOME" - - virtualenvwrapper_run_hook "pre_rmvirtualenv" "$env_name" - command \rm -rf "$env_dir" - virtualenvwrapper_run_hook "post_rmvirtualenv" "$env_name" - - # If the directory we used to be in still exists, move back to it. - if [ -d "$prior_dir" ] - then - virtualenvwrapper_cd "$prior_dir" - fi - done -} - -# List the available environments. -function virtualenvwrapper_show_workon_options { - virtualenvwrapper_verify_workon_home || return 1 - # NOTE: DO NOT use ls or cd here because colorized versions spew control - # characters into the output list. - # echo seems a little faster than find, even with -depth 3. - # Note that this is a little tricky, as there may be spaces in the path. - # - # 1. Look for environments by finding the activate scripts. - # Use a subshell so we can suppress the message printed - # by zsh if the glob pattern fails to match any files. - # This yields a single, space-separated line containing all matches. - # 2. Replace the trailing newline with a space, so every - # possible env has a space following it. - # 3. Strip the bindir/activate script suffix, replacing it with - # a slash, as that is an illegal character in a directory name. - # This yields a slash-separated list of possible env names. - # 4. Replace each slash with a newline to show the output one name per line. - # 5. Eliminate any lines with * on them because that means there - # were no envs. - (virtualenvwrapper_cd "$WORKON_HOME" && echo */$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate) 2>/dev/null \ - | command \tr "\n" " " \ - | command \sed "s|/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate |/|g" \ - | command \tr "/" "\n" \ - | command \sed "/^\s*$/d" \ - | (unset GREP_OPTIONS; command \egrep -v '^\*$') 2>/dev/null -} - -function _lsvirtualenv_usage { - echo "lsvirtualenv [-blh]" - echo " -b -- brief mode" - echo " -l -- long mode" - echo " -h -- this help message" -} - -#:help:lsvirtualenv: list virtualenvs -function lsvirtualenv { - - typeset long_mode=true - if command -v "getopts" &> /dev/null - then - # Use getopts when possible - OPTIND=1 - while getopts ":blh" opt "$@" - do - case "$opt" in - l) long_mode=true;; - b) long_mode=false;; - h) _lsvirtualenv_usage; - return 1;; - ?) echo "Invalid option: -$OPTARG" >&2; - _lsvirtualenv_usage; - return 1;; - esac - done - else - # fallback on getopt for other shell - typeset -a args - args=($(getopt blh "$@")) - if [ $? != 0 ] - then - _lsvirtualenv_usage - return 1 - fi - for opt in $args - do - case "$opt" in - -l) long_mode=true;; - -b) long_mode=false;; - -h) _lsvirtualenv_usage; - return 1;; - esac - done - fi - - if $long_mode - then - allvirtualenv showvirtualenv "$env_name" - else - virtualenvwrapper_show_workon_options - fi -} - -#:help:showvirtualenv: show details of a single virtualenv -function showvirtualenv { - typeset env_name="$1" - if [ -z "$env_name" ] - then - if [ -z "$VIRTUAL_ENV" ] - then - echo "showvirtualenv [env]" - return 1 - fi - env_name=$(basename "$VIRTUAL_ENV") - fi - - virtualenvwrapper_run_hook "get_env_details" "$env_name" - echo -} - -# Show help for workon -function virtualenvwrapper_workon_help { - echo "Usage: workon env_name" - echo "" - echo " Deactivate any currently activated virtualenv" - echo " and activate the named environment, triggering" - echo " any hooks in the process." - echo "" - echo " workon" - echo "" - echo " Print a list of available environments." - echo " (See also lsvirtualenv -b)" - echo "" - echo " workon (-h|--help)" - echo "" - echo " Show this help message." - echo "" - echo " workon (-c|--cd) envname" - echo "" - echo " After activating the environment, cd to the associated" - echo " project directory if it is set." - echo "" - echo " workon (-n|--no-cd) envname" - echo "" - echo " After activating the environment, do not cd to the" - echo " associated project directory." - echo "" -} - -#:help:workon: list or change working virtualenvs -function workon { - typeset -a in_args - typeset -a out_args - - in_args=( "$@" ) - - if [ -n "$ZSH_VERSION" ] - then - i=1 - tst="-le" - else - i=0 - tst="-lt" - fi - typeset cd_after_activate=$VIRTUALENVWRAPPER_WORKON_CD - while [ $i $tst $# ] - do - a="${in_args[$i]}" - case "$a" in - -h|--help) - virtualenvwrapper_workon_help; - return 0;; - -n|--no-cd) - cd_after_activate=0;; - -c|--cd) - cd_after_activate=1;; - *) - if [ ${#out_args} -gt 0 ] - then - out_args=( "${out_args[@]-}" "$a" ) - else - out_args=( "$a" ) - fi;; - esac - i=$(( $i + 1 )) - done - - set -- "${out_args[@]}" - - typeset env_name="$1" - if [ "$env_name" = "" ] - then - lsvirtualenv -b - return 1 - elif [ "$env_name" = "." ] - then - # The IFS default of breaking on whitespace causes issues if there - # are spaces in the env_name, so change it. - IFS='%' - env_name="$(basename $(pwd))" - unset IFS - fi - - virtualenvwrapper_verify_workon_home || return 1 - virtualenvwrapper_verify_workon_environment "$env_name" || return 1 - - activate="$WORKON_HOME/$env_name/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate" - if [ ! -f "$activate" ] - then - echo "ERROR: Environment '$WORKON_HOME/$env_name' does not contain an activate script." >&2 - return 1 - fi - - # Deactivate any current environment "destructively" - # before switching so we use our override function, - # if it exists. - type deactivate >/dev/null 2>&1 - if [ $? -eq 0 ] - then - deactivate - unset -f deactivate >/dev/null 2>&1 - fi - - virtualenvwrapper_run_hook "pre_activate" "$env_name" - - source "$activate" - - # Save the deactivate function from virtualenv under a different name - virtualenvwrapper_original_deactivate=`typeset -f deactivate | sed 's/deactivate/virtualenv_deactivate/g'` - eval "$virtualenvwrapper_original_deactivate" - unset -f deactivate >/dev/null 2>&1 - - # Replace the deactivate() function with a wrapper. - eval 'deactivate () { - typeset env_postdeactivate_hook - typeset old_env - - # Call the local hook before the global so we can undo - # any settings made by the local postactivate first. - virtualenvwrapper_run_hook "pre_deactivate" - - env_postdeactivate_hook="$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/postdeactivate" - old_env=$(basename "$VIRTUAL_ENV") - - # Call the original function. - virtualenv_deactivate $1 - - virtualenvwrapper_run_hook "post_deactivate" "$old_env" - - if [ ! "$1" = "nondestructive" ] - then - # Remove this function - unset -f virtualenv_deactivate >/dev/null 2>&1 - unset -f deactivate >/dev/null 2>&1 - fi - - }' - - VIRTUALENVWRAPPER_PROJECT_CD=$cd_after_activate virtualenvwrapper_run_hook "post_activate" - - return 0 -} - - -# Prints the Python version string for the current interpreter. -function virtualenvwrapper_get_python_version { - # Uses the Python from the virtualenv rather than - # VIRTUALENVWRAPPER_PYTHON because we're trying to determine the - # version installed there so we can build up the path to the - # site-packages directory. - "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/python" -V 2>&1 | cut -f2 -d' ' | cut -f-2 -d. -} - -# Prints the path to the site-packages directory for the current environment. -function virtualenvwrapper_get_site_packages_dir { - "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/python" -c "import distutils; print(distutils.sysconfig.get_python_lib())" -} - -# Path management for packages outside of the virtual env. -# Based on a contribution from James Bennett and Jannis Leidel. -# -# add2virtualenv directory1 directory2 ... -# -# Adds the specified directories to the Python path for the -# currently-active virtualenv. This will be done by placing the -# directory names in a path file named -# "virtualenv_path_extensions.pth" inside the virtualenv's -# site-packages directory; if this file does not exist, it will be -# created first. -# -#:help:add2virtualenv: add directory to the import path -function add2virtualenv { - virtualenvwrapper_verify_workon_home || return 1 - virtualenvwrapper_verify_active_environment || return 1 - - site_packages="`virtualenvwrapper_get_site_packages_dir`" - - if [ ! -d "${site_packages}" ] - then - echo "ERROR: currently-active virtualenv does not appear to have a site-packages directory" >&2 - return 1 - fi - - # Prefix with _ to ensure we are loaded as early as possible, - # and at least before easy_install.pth. - path_file="$site_packages/_virtualenv_path_extensions.pth" - - if [ "$*" = "" ] - then - echo "Usage: add2virtualenv dir [dir ...]" - if [ -f "$path_file" ] - then - echo - echo "Existing paths:" - cat "$path_file" | grep -v "^import" - fi - return 1 - fi - - remove=0 - if [ "$1" = "-d" ] - then - remove=1 - shift - fi - - if [ ! -f "$path_file" ] - then - echo "import sys; sys.__plen = len(sys.path)" > "$path_file" || return 1 - echo "import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new)" >> "$path_file" || return 1 - fi - - for pydir in "$@" - do - absolute_path="$(virtualenvwrapper_absolutepath "$pydir")" - if [ "$absolute_path" != "$pydir" ] - then - echo "Warning: Converting \"$pydir\" to \"$absolute_path\"" 1>&2 - fi - - if [ $remove -eq 1 ] - then - sed -i.tmp "\:^$absolute_path$: d" "$path_file" - else - sed -i.tmp '1 a\ -'"$absolute_path"' -' "$path_file" - fi - rm -f "${path_file}.tmp" - done - return 0 -} - -# Does a ``cd`` to the site-packages directory of the currently-active -# virtualenv. -#:help:cdsitepackages: change to the site-packages directory -function cdsitepackages { - virtualenvwrapper_verify_workon_home || return 1 - virtualenvwrapper_verify_active_environment || return 1 - typeset site_packages="`virtualenvwrapper_get_site_packages_dir`" - virtualenvwrapper_cd "$site_packages/$1" -} - -# Does a ``cd`` to the root of the currently-active virtualenv. -#:help:cdvirtualenv: change to the $VIRTUAL_ENV directory -function cdvirtualenv { - virtualenvwrapper_verify_workon_home || return 1 - virtualenvwrapper_verify_active_environment || return 1 - virtualenvwrapper_cd "$VIRTUAL_ENV/$1" -} - -# Shows the content of the site-packages directory of the currently-active -# virtualenv -#:help:lssitepackages: list contents of the site-packages directory -function lssitepackages { - virtualenvwrapper_verify_workon_home || return 1 - virtualenvwrapper_verify_active_environment || return 1 - typeset site_packages="`virtualenvwrapper_get_site_packages_dir`" - ls $@ "$site_packages" - - path_file="$site_packages/_virtualenv_path_extensions.pth" - if [ -f "$path_file" ] - then - echo - echo "_virtualenv_path_extensions.pth:" - cat "$path_file" - fi -} - -# Toggles the currently-active virtualenv between having and not having -# access to the global site-packages. -#:help:toggleglobalsitepackages: turn access to global site-packages on/off -function toggleglobalsitepackages { - virtualenvwrapper_verify_workon_home || return 1 - virtualenvwrapper_verify_active_environment || return 1 - typeset no_global_site_packages_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt" - if [ -f $no_global_site_packages_file ]; then - rm $no_global_site_packages_file - [ "$1" = "-q" ] || echo "Enabled global site-packages" - else - touch $no_global_site_packages_file - [ "$1" = "-q" ] || echo "Disabled global site-packages" - fi -} - -#:help:cpvirtualenv: duplicate the named virtualenv to make a new one -function cpvirtualenv { - virtualenvwrapper_verify_workon_home || return 1 - virtualenvwrapper_verify_virtualenv_clone || return 1 - - typeset src_name="$1" - typeset trg_name="$2" - typeset src - typeset trg - - # without a source there is nothing to do - if [ "$src_name" = "" ]; then - echo "Please provide a valid virtualenv to copy." - return 1 - else - # see if it's already in workon - if [ ! -e "$WORKON_HOME/$src_name" ]; then - # so it's a virtualenv we are importing - # make sure we have a full path - # and get the name - src="$(virtualenvwrapper_expandpath "$src_name")" - # final verification - if [ ! -e "$src" ]; then - echo "Please provide a valid virtualenv to copy." - return 1 - fi - src_name="$(basename "$src")" - else - src="$WORKON_HOME/$src_name" - fi - fi - - if [ "$trg_name" = "" ]; then - # target not given, assume - # same as source - trg="$WORKON_HOME/$src_name" - trg_name="$src_name" - else - trg="$WORKON_HOME/$trg_name" - fi - trg="$(virtualenvwrapper_expandpath "$trg")" - - # validate trg does not already exist - # catch copying virtualenv in workon home - # to workon home - if [ -e "$trg" ]; then - echo "$trg_name virtualenv already exists." - return 1 - fi - - echo "Copying $src_name as $trg_name..." - ( - [ -n "$ZSH_VERSION" ] && setopt SH_WORD_SPLIT - virtualenvwrapper_cd "$WORKON_HOME" && - "$VIRTUALENVWRAPPER_VIRTUALENV_CLONE" "$src" "$trg" - [ -d "$trg" ] && - virtualenvwrapper_run_hook "pre_cpvirtualenv" "$src" "$trg_name" && - virtualenvwrapper_run_hook "pre_mkvirtualenv" "$trg_name" - ) - typeset RC=$? - [ $RC -ne 0 ] && return $RC - - [ ! -d "$WORKON_HOME/$trg_name" ] && return 1 - - # Now activate the new environment - workon "$trg_name" - - virtualenvwrapper_run_hook "post_mkvirtualenv" - virtualenvwrapper_run_hook "post_cpvirtualenv" -} - -# -# virtualenvwrapper project functions -# - -# Verify that the PROJECT_HOME directory exists -function virtualenvwrapper_verify_project_home { - if [ -z "$PROJECT_HOME" ] - then - echo "ERROR: Set the PROJECT_HOME shell variable to the name of the directory where projects should be created." >&2 - return 1 - fi - if [ ! -d "$PROJECT_HOME" ] - then - [ "$1" != "-q" ] && echo "ERROR: Project directory '$PROJECT_HOME' does not exist. Create it or set PROJECT_HOME to an existing directory." >&2 - return 1 - fi - return 0 -} - -# Given a virtualenv directory and a project directory, -# set the virtualenv up to be associated with the -# project -#:help:setvirtualenvproject: associate a project directory with a virtualenv -function setvirtualenvproject { - typeset venv="$1" - typeset prj="$2" - if [ -z "$venv" ] - then - venv="$VIRTUAL_ENV" - fi - if [ -z "$prj" ] - then - prj="$(pwd)" - else - prj=$(virtualenvwrapper_absolutepath "${prj}") - fi - - # If what we were given isn't a directory, see if it is under - # $WORKON_HOME. - if [ ! -d "$venv" ] - then - venv="$WORKON_HOME/$venv" - fi - if [ ! -d "$venv" ] - then - echo "No virtualenv $(basename $venv)" 1>&2 - return 1 - fi - - # Make sure we have a valid project setting - if [ ! -d "$prj" ] - then - echo "Cannot associate virtualenv with \"$prj\", it is not a directory" 1>&2 - return 1 - fi - - echo "Setting project for $(basename $venv) to $prj" - echo "$prj" > "$venv/$VIRTUALENVWRAPPER_PROJECT_FILENAME" -} - -# Show help for mkproject -function virtualenvwrapper_mkproject_help { - echo "Usage: mkproject [-f|--force] [-t template] [virtualenv options] project_name" - echo - echo "-f, --force Create the virtualenv even if the project directory" - echo " already exists" - echo - echo "Multiple templates may be selected. They are applied in the order" - echo "specified on the command line." - echo - echo "mkvirtualenv help:" - echo - mkvirtualenv -h - echo - echo "Available project templates:" - echo - "$VIRTUALENVWRAPPER_PYTHON" -c 'from virtualenvwrapper.hook_loader import main; main()' -l project.template -} - -#:help:mkproject: create a new project directory and its associated virtualenv -function mkproject { - typeset -a in_args - typeset -a out_args - typeset -i i - typeset tst - typeset a - typeset t - typeset force - typeset templates - - in_args=( "$@" ) - force=0 - - if [ -n "$ZSH_VERSION" ] - then - i=1 - tst="-le" - else - i=0 - tst="-lt" - fi - while [ $i $tst $# ] - do - a="${in_args[$i]}" - case "$a" in - -h|--help) - virtualenvwrapper_mkproject_help; - return;; - -f|--force) - force=1;; - -t) - i=$(( $i + 1 )); - templates="$templates ${in_args[$i]}";; - *) - if [ ${#out_args} -gt 0 ] - then - out_args=( "${out_args[@]-}" "$a" ) - else - out_args=( "$a" ) - fi;; - esac - i=$(( $i + 1 )) - done - - set -- "${out_args[@]}" - - # echo "templates $templates" - # echo "remainder $@" - # return 0 - - eval "typeset envname=\$$#" - virtualenvwrapper_verify_project_home || return 1 - - if [ -d "$PROJECT_HOME/$envname" -a $force -eq 0 ] - then - echo "Project $envname already exists." >&2 - return 1 - fi - - mkvirtualenv "$@" || return 1 - - virtualenvwrapper_cd "$PROJECT_HOME" - - virtualenvwrapper_run_hook "project.pre_mkproject" $envname - - echo "Creating $PROJECT_HOME/$envname" - mkdir -p "$PROJECT_HOME/$envname" - setvirtualenvproject "$VIRTUAL_ENV" "$PROJECT_HOME/$envname" - - virtualenvwrapper_cd "$PROJECT_HOME/$envname" - - for t in $templates - do - echo - echo "Applying template $t" - # For some reason zsh insists on prefixing the template - # names with a space, so strip them out before passing - # the value to the hook loader. - virtualenvwrapper_run_hook --name $(echo $t | sed 's/^ //') "project.template" "$envname" "$PROJECT_HOME/$envname" - done - - virtualenvwrapper_run_hook "project.post_mkproject" -} - -#:help:cdproject: change directory to the active project -function cdproject { - virtualenvwrapper_verify_workon_home || return 1 - virtualenvwrapper_verify_active_environment || return 1 - if [ -f "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME" ] - then - typeset project_dir="$(cat "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME")" - if [ ! -z "$project_dir" ] - then - virtualenvwrapper_cd "$project_dir" - else - echo "Project directory $project_dir does not exist" 1>&2 - return 1 - fi - else - echo "No project set in $VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME" 1>&2 - return 1 - fi - return 0 -} - -# -# Temporary virtualenv -# -# Originally part of virtualenvwrapper.tmpenv plugin -# -#:help:mktmpenv: create a temporary virtualenv -function mktmpenv { - typeset tmpenvname - typeset RC - typeset -a in_args - typeset -a out_args - - in_args=( "$@" ) - - if [ -n "$ZSH_VERSION" ] - then - i=1 - tst="-le" - else - i=0 - tst="-lt" - fi - typeset cd_after_activate=$VIRTUALENVWRAPPER_WORKON_CD - while [ $i $tst $# ] - do - a="${in_args[$i]}" - case "$a" in - -n|--no-cd) - cd_after_activate=0;; - -c|--cd) - cd_after_activate=1;; - *) - if [ ${#out_args} -gt 0 ] - then - out_args=( "${out_args[@]-}" "$a" ) - else - out_args=( "$a" ) - fi;; - esac - i=$(( $i + 1 )) - done - - set -- "${out_args[@]}" - - # Generate a unique temporary name - tmpenvname=$("$VIRTUALENVWRAPPER_PYTHON" -c 'import uuid,sys; sys.stdout.write(uuid.uuid4()+"\n")' 2>/dev/null) - if [ -z "$tmpenvname" ] - then - # This python does not support uuid - tmpenvname=$("$VIRTUALENVWRAPPER_PYTHON" -c 'import random,sys; sys.stdout.write(hex(random.getrandbits(64))[2:-1]+"\n")' 2>/dev/null) - fi - tmpenvname="tmp-$tmpenvname" - - # Create the environment - mkvirtualenv "$@" "$tmpenvname" - RC=$? - if [ $RC -ne 0 ] - then - return $RC - fi - - # Change working directory - [ "$cd_after_activate" = "1" ] && cdvirtualenv - - # Create the tmpenv marker file - echo "This is a temporary environment. It will be deleted when you run 'deactivate'." | tee "$VIRTUAL_ENV/README.tmpenv" - - # Update the postdeactivate script - cat - >> "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/postdeactivate" < "$req_file" - if [ -n "$(cat "$req_file")" ] - then - echo "Uninstalling packages:" - cat "$req_file" - echo - pip uninstall -y $(cat "$req_file" | grep -v '^-f' | sed 's/>/=/g' | cut -f1 -d=) - else - echo "Nothing to remove." - fi - rm -f "$req_file" -} - -# -# Run a command in each virtualenv -# -#:help:allvirtualenv: run a command in all virtualenvs -function allvirtualenv { - virtualenvwrapper_verify_workon_home || return 1 - typeset d - - # The IFS default of breaking on whitespace causes issues if there - # are spaces in the env_name, so change it. - IFS='%' - virtualenvwrapper_show_workon_options | while read d - do - [ ! -d "$WORKON_HOME/$d" ] && continue - echo "$d" - echo "$d" | sed 's/./=/g' - # Activate the environment, but not with workon - # because we don't want to trigger any hooks. - (source "$WORKON_HOME/$d/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate"; - virtualenvwrapper_cd "$VIRTUAL_ENV"; - "$@") - echo - done - unset IFS -} - -#:help:virtualenvwrapper: show this help message -function virtualenvwrapper { - cat < /dev/null -# VIRTUALENVWRAPPER_PYTHON=python3 -export PYTHONBREAKPOINT=ipdb.set_trace -source ~/.zshenv - -# Color man pages -export LESS_TERMCAP_mb=$'\e[1;32m' -export LESS_TERMCAP_md=$'\e[1;32m' -export LESS_TERMCAP_me=$'\e[0m' -export LESS_TERMCAP_se=$'\e[0m' -export LESS_TERMCAP_so=$'\e[01;33m' -export LESS_TERMCAP_ue=$'\e[0m' -export LESS_TERMCAP_us=$'\e[1;4;31m' - -# Enable extended glob -setopt extendedglob - -# Enable Ctrl-x-e to edit command line -autoload -U edit-command-line -# Emacs style -zle -N edit-command-line -bindkey '^xe' edit-command-line -bindkey '^x^e' edit-command-line -# Vi style: -# zle -N edit-command-line -# bindkey -M vicmd v edit-command-line - -# add GO to path -export PATH="/home/viktor/go/bin:$PATH" -#export GO111MODULE=on -export GOPATH="/home/$USER/go" - -# add JDK 12 go path -export PATH="/opt/jdk-12.0.1/bin:$PATH" - -# add azure core tools to path -# export PATH="/opt/azure/:$PATH" - -unset command_not_found_handle - -# Load nvm -export NVM_DIR="$HOME/.nvm" -[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"# This loads nvm -[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"# This loads nvm bash_completion - -export PATH="/home/viktor/.local/bin:$PATH" - -# Load Z to jump around recent dirs -#. ~/z.sh - -compinit - -# add k8s autocompletion, must be after compinit! -if which kubectl >/dev/null 2>/dev/null; then - source <(kubectl completion zsh) -fi diff --git a/setup.sh b/setup.sh deleted file mode 100755 index 5bcc39b..0000000 --- a/setup.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash - -set -e - -# Get packet manager -if [ -x "$(command -v apk)" ]; then pm=apk -elif [ -x "$(command -v apt)" ]; then pm="apt" -elif [ -x "$(command -v dnf)" ]; then pm="dnf" -elif [ -x "$(command -v zypper)" ];then pm="zypper" -else echo "FAILED TO INSTALL PACKAGE: Package manager not found. You must manually install: zsh tmux wget" -fi - -# Install zsh -if which zsh 2>/dev/null > /dev/null && which tmux 2>/dev/null >/dev/null && which wget 2>/dev/null >/dev/null; then - echo "All needed packages are installed. Skipping install step" -else - echo "Installing zsh, tmux and wget..." - sudo $pm install -y zsh tmux wget -fi - -# Setup oh-my-zsh -wget -O /tmp/install.sh https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -chmod +x /tmp/install.sh -set +e -echo "exit" | /tmp/install.sh -set -e -rm /tmp/install.sh - -# Setup zsh config files -wget -O ~/.zshrc https://raw.githubusercontent.com/ViktorBarzin/dot_files/master/.zshrc && \ -wget -O ~/.bash_aliases https://raw.githubusercontent.com/ViktorBarzin/dot_files/master/.bash_aliases && \ -wget -O ~/.zshenv https://raw.githubusercontent.com/ViktorBarzin/dot_files/master/.zshenv && \ - -# Setup tmux -bash -c "cd ~ && git clone https://github.com/gpakosz/.tmux.git && ln -s -f .tmux/.tmux.conf && cp .tmux/.tmux.conf.local ." - -wget -O ~/.tmux.conf.local https://raw.githubusercontent.com/ViktorBarzin/dot_files/master/.tmux.conf.local && \ - -# Configure z (jump) -# git clone https://github.com/agkozak/zsh-z $ZSH_CUSTOM/plugins/zsh-z && \ -git clone https://github.com/agkozak/zsh-z ~/.oh-my-zsh/plugins/zsh-z && \ - -echo ' - ___ _ _ ___ ___ ___ ___ ___ - / __| | | |/ __/ __/ _ \/ __/ __| - \__ \ |_| | (_| (_| __/\__ \__ \ - |___/\__,_|\___\___\___||___/___/ - - -' && \ -echo ' Run tmux to enter your newly setup environment!' -