This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# You can call this script like this: | |
# $ ./brightnessControl.sh up | |
# $ ./brightnessControl.sh down | |
# Script inspired by these wonderful people: | |
# https://github.com/dastorm/volume-notification-dunst/blob/master/volume.sh | |
# https://gist.github.com/sebastiencs/5d7227f388d93374cebdf72e783fbd6a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pacman aliases | |
alias pac='pacman -S' # install | |
alias pacu='pacman -Syu' # update, add 'a' to the list of letters to update AUR packages if you use yaourt | |
alias pacr='pacman -Rs' # remove | |
alias pacs='pacman -Ss' # search | |
alias paci='pacman -Si' # info | |
alias paclo='pacman -Qdt' # list orphans | |
alias pacro='paclo && sudo pacman -Rns $(pacman -Qtdq)' # remove orphans | |
alias pacc='pacman -Scc' # clean cache | |
alias paclf='pacman -Ql' # list files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a general-purpose function to ask Yes/No questions in Bash, either | |
# with or without a default answer. It keeps repeating the question until it | |
# gets a valid answer. | |
ask() { | |
# https://gist.github.com/davejamesmiller/1965569 | |
local prompt default reply | |
if [ "${2:-}" = "Y" ]; then | |
prompt="Y/n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: https://unix.stackexchange.com/a/115431 | |
#!/usr/bin/env zsh | |
# only file- / script name | |
echo ${0:a} | |
#!/usr/bin/env zsh | |
# file- / script name with path | |
echo ${0:a:h} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://bougui505.github.io/2016/02/29/zsh_string_manipulation-_split_string.html | |
Split string in a given word separator (ws) | |
For example _: | |
# x="foo_1" | |
# echo $x[(ws:_:)1] | |
foo | |
# echo $x[(ws:_:)2] | |
1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://zaiste.net/zsh_get_filename_extension_path/#!/bin/zsh | |
# Filename | |
fullpath="/etc/nginx/nginx.conf" | |
filename=$fullpath:t | |
echo $filename | |
nginx.conf | |
# Path | |
fullpath="/etc/nginx/nginx.conf" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ּ_בּ | |
בּ_בּ | |
טּ_טּ | |
כּ‗כּ | |
לּ_לּ | |
מּ_מּ | |
סּ_סּ | |
תּ_תּ | |
٩(×̯×)۶ | |
٩(̾●̮̮̃̾•̃̾)۶ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Depends on GitPython | |
pip install GitPython | |
""" | |
from git import Repo | |
def get_current_branch_name(repo_path) | |
""" | |
Gets the name of the active Git branch as a string. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Bash: How to output command to next prompt for user to use? | |
Source: https://superuser.com/a/1130773 | |
MY_COMMAND="ls" | |
MY_PARAMS=() | |
read -a MY_PARAMS -p $MY_COMMAND | |
exec $MY_COMMAND ${MY_PARAMS[@]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# test: get ids of all open browser windows | |
wins=$(xdotool search --screen 0 --onlyvisible --class "qutebrowser") | |
echo $wins | |
# > 16777247 | |
# > 16785319 | |
# > 16786158 | |
# get id of second window | |
win=$(xdotool search --screen 0 --onlyvisible --class "qutebrowser" | head -2 | tail -1) |