Skip to content

Instantly share code, notes, and snippets.

View imvaskii's full-sized avatar
🎯
Focusing

Bhaskar imvaskii

🎯
Focusing
View GitHub Profile
@imvaskii
imvaskii / floating-fzf.vim
Created July 9, 2020 22:23
Vim Floating Window
" floating fzf window with borders
function! CreateCenteredFloatingWindow()
let width = min([&columns - 4, max([80, &columns - 20])])
let height = min([&lines - 4, max([20, &lines - 10])])
let top = ((&lines - height) / 2) - 1
let left = (&columns - width) / 2
let opts = {'relative': 'editor', 'row': top, 'col': left, 'width': width, 'height': height, 'style': 'minimal'}
let top = "╭" . repeat("─", width - 2) . "╮"
@imvaskii
imvaskii / .tmux.conf
Created April 16, 2020 10:23
~/.tmux.conf
# tmux config file.
#
# Maintainer: Bhaskar K C <[email protected]>
unbind C-b
# edit configuration
bind e new-window -n "~/.tmux.conf" \
"sh -c '\${EDITOR:-vim} \
~.tmux.conf && \
tmux source ~/.tmux.conf && \
@imvaskii
imvaskii / .xprofile
Last active April 19, 2020 13:12
Xprofile
#!/usr/bin/env sh
#
# Author: Bhaskar K <[email protected]>
# Switch to US international with Caps as Mod/Escape
setxkbmap -option caps:super -variant altgr-intl
killall xcape 2>/dev/null
xcape -e 'Super_L=Escape'
xmodmap -e 'keycode 135 = Super_R' &
@imvaskii
imvaskii / extend.sh
Created December 20, 2019 21:14 — forked from wvengen/extend.sh
Extend non-HiDPI external display above HiDPI internal display
#!/bin/sh
# extend non-HiDPI external display on DP* above HiDPI internal display eDP*
# see also https://wiki.archlinux.org/index.php/HiDPI
# you may run into https://bugs.freedesktop.org/show_bug.cgi?id=39949
# https://bugs.launchpad.net/ubuntu/+source/xorg-server/+bug/883319
EXT=`xrandr --current | sed 's/^\(.*\) connected.*$/\1/p;d' | grep -v ^eDP | head -n 1`
INT=`xrandr --current | sed 's/^\(.*\) connected.*$/\1/p;d' | grep -v ^DP | head -n 1`
ext_w=`xrandr | sed 's/^'"${EXT}"' [^0-9]* \([0-9]\+\)x.*$/\1/p;d'`
set shell=/usr/bin/bash
if &compatible
set nocompatible
endif
" Declare the general config group for autocommand
if has("autocmd")
augroup vimrc
@imvaskii
imvaskii / git-prev-and-current-hash.sh
Created December 7, 2019 04:37
Bash fn for current and prev commit hash.
#!/bin/env bash
# Current commit HASH
# %H give commit hash
current_commit() {
git HEAD --pretty=format:"%H"
# git log -n 1 --pretty=format:"%H"
}
# Previous commit HASH
@imvaskii
imvaskii / repeat_string.sh
Created December 2, 2019 09:00
Bash script to repeat strings.
#!/usr/bin/env bash
# Repeat String
#
# Usage repeat_string "-"
# repeat_string "-" 20
# ARG1: String
# ARG2: Count [optional]
repeat_string() {
sep=$1
m
:
@imvaskii
imvaskii / listen-hdmi.sh
Last active October 24, 2019 02:29
Bash scrip to executes xrandr layout for hdmi monitors.
#!/usr/bin/env bash
xrandr=$(xrandr)
con_monitors=$(echo $xrandr | grep -c " connected ")
if [[ $con_monitors -gt 1 ]]; then
# All the layouts are saved in "screenlayout" folder.
# eg. xrandr --output HDMI-1 --mode 2560x1440 --pos 0x0 --rotate normal --output DP-1 --off --output eDP-1 --primary --mode 1920x1080 --pos 283x1440 --rotate normal --output DP-2 --off
for layout in ~/.screenlayout/*.sh; do
@imvaskii
imvaskii / bash_in_array.sh
Created March 19, 2019 10:18
Bash in_array function.
# Check item in an array
#
# @arg1 needle
# @arg2 array
#
# return boolean
inarray() {
for item in "${@:2}"; do [[ "$item" == "$1" ]] && return 0; done
return 1
}