summary refs log tree commit diff stats
path: root/examples/bash_automatic_cd.sh
blob: 465c9c808372eb8def19097602f1c25f84421da0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Compatible with ranger 1.4.2 through 1.6.*
#
# Automatically change the directory in bash after closing ranger
#
# This is a bash function for .bashrc to automatically change the directory to
# the last visited one after ranger quits.
# To undo the effect of this function, you can type "cd -" to return to the
# original directory.

function ranger-cd {
    tempfile="$(mktemp)"
    /usr/bin/ranger --choosedir="$tempfile" "${@:-$(pwd)}"
    test -f "$tempfile" &&
    if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then
        cd -- "$(cat "$tempfile")"
    fi
    rm -f -- "$tempfile"
}

# This binds Ctrl-O to ranger-cd:
bind '"\C-o":"ranger-cd\C-m"'
an>initializes variables in memory to 0 var result/xmm1: float <- to-km zero compare result, zero { break-if-= draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "F - 0 miles = 0 km\n", 3/fg 0/bg count-test-failure } # 1 mile = 1.609 km approximately var one/eax: int <- copy 1 var one-float/xmm0: float <- convert one result <- to-km one-float var lower-bound/xmm0: float <- rational 0x649, 0x3e8 # 1609/1000 in hex { compare result, lower-bound break-if-float>= draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "F - 1 mile > 1.609 km\n", 3/fg 0/bg count-test-failure } var upper-bound/xmm0: float <- rational 0x64a, 0x3e8 # 1610/1000 in hex { compare result, upper-bound break-if-float<= draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "F - 1 mile < 1.610 km\n", 3/fg 0/bg count-test-failure } # 2 miles = 3.218 km approximately var two/eax: int <- copy 2 var two-float/xmm0: float <- convert two result <- to-km two-float var lower-bound/xmm0: float <- rational 0xc92, 0x3e8 # 3218/1000 in hex { compare result, lower-bound break-if-float>= draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "F - 2 miles > 3.218 km\n", 3/fg 0/bg count-test-failure } var upper-bound/xmm0: float <- rational 0xc93, 0x3e8 # 3219/1000 in hex { compare result, upper-bound break-if-float<= draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "F - 2 miles < 3.219 km\n", 3/fg 0/bg count-test-failure } } fn main { }