Skip to content

Commit ed60529

Browse files
author
Diggory Hardy
committed
Add several small scripts
1 parent a5be0a3 commit ed60529

File tree

6 files changed

+100
-0
lines changed

6 files changed

+100
-0
lines changed

bashrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ alias gc='git commit'
107107
alias gb='git branch'
108108
alias gcp='git checkout -p --'
109109
alias grH='git reset HEAD --'
110+
alias grv='git remote -v'
111+
alias gba='git branch -a'
110112

111113
# Add an "alert" alias for long running commands. Use like so:
112114
# sleep 10; alert

disp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
DISPER=$(which disper 2>/dev/null)
4+
XRANDR=$(which xrandr 2>/dev/null)
5+
NVSETTINGS=$(which nvidia-settings 2>/dev/null)
6+
XRANDR_ROT="-o normal"
7+
8+
XRANDR_L="$(xrandr | grep LVDS | cut -d' ' -f1)"
9+
# this may be DP2 or something else:
10+
XRANDR_E="$(xrandr | egrep "^DP.*\bconnected\b" | cut -d' ' -f1)"
11+
12+
if [ "$1" = "l" ]
13+
then
14+
echo "Switching to laptop display"
15+
DISPER_OPT="-s"
16+
XRANDR_OPT="--output $XRANDR_L --auto --output $XRANDR_E --off"
17+
elif [ "$1" = "e" ] || [ "$1" = "d" ]
18+
then
19+
echo "Switching to dock display"
20+
DISPER_OPT="-S"
21+
XRANDR_OPT="--output $XRANDR_E --auto --output $XRANDR_L --off"
22+
else
23+
echo "Usage: $0 D [R]"
24+
echo "where D is l for laptop display or d for dock display"
25+
echo "and R is l for "left" portrait orientation"
26+
echo "Listing displays:"
27+
DISPER_OPT="-l"
28+
XRANDR_OPT=""
29+
XRANDR_ROT=""
30+
fi
31+
if [ "$2" = "l" ]
32+
then
33+
echo "Orientation: left"
34+
XRANDR_ROT="-o left"
35+
fi
36+
37+
#TODO: apparently this tries executing nvidia-settings when it's not found:
38+
if [ -f "$NVSETTINGS" -a "$(nvidia-settings --glxinfo | grep NVIDIA)x" != "x" ]
39+
then
40+
echo "Detected NVIDIA driver, using disper" >&2
41+
$DISPER $DISPER_OPT
42+
$XRANDR $XRANDR_ROT
43+
else
44+
echo "Using xrandr" >&2
45+
$XRANDR $XRANDR_OPT $XRANDR_ROT
46+
fi
47+

nice_make

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
nice -n 2 make $@
3+

old/kde-trash

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
for f in "$@"
3+
do
4+
echo -n "Moving $f to trash bin..."
5+
kioclient move "$f" trash:/
6+
echo -n " num items in trash: "
7+
ls $HOME/.local/share/Trash/info | wc -l
8+
done
9+

old/l

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/python
2+
# -*- coding: utf-8 -*-
3+
# Program to call either ls or less
4+
5+
import os.path
6+
import subprocess
7+
import sys
8+
9+
def main(args):
10+
ndirs=0
11+
nfiles=0
12+
for arg in args[1:]:
13+
if len(arg)>=2 and arg[0]=='-':
14+
continue
15+
if os.path.isfile(arg):
16+
nfiles+=1
17+
elif os.path.isdir(arg):
18+
ndirs+=1
19+
else:
20+
print "Not a file or directory:",arg
21+
print "Usage:",args[0],"PATH [PATH [...]]"
22+
print "where PATH is a file or directory. ls or less is called appropriately."
23+
return -1
24+
print nfiles,"files and",ndirs,"dirs"
25+
if ndirs==0 and nfiles>0:
26+
"""at least one file but no directory: less"""
27+
return subprocess.call(["less"]+args[1:])
28+
else:
29+
"""no args or args include dirs: ls"""
30+
return subprocess.call(["ls","--color=auto"]+args[1:])
31+
32+
if __name__ == "__main__":
33+
sys.exit(main(sys.argv))

open

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
for arg in "$@";
3+
do
4+
xdg-open "$arg"
5+
done
6+

0 commit comments

Comments
 (0)